The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Sort::Key::OID - sort OIDs very fast


  use Sort::Key::OID qw(oidsort);
  my @data = qw(1 1.2 1.1.3 1.1);
  my @sorted = oidsort @data;


This module extends the Sort::Key family of modules to support sorting of OID values.

Also, once this module is loaded, the new type oid will be available from Sort::Key::Maker.

Valid OIDs are sequences of unsigned integers separated by some symbol. For instance:  # valid
   1-2-3-45  # valid
   1 2 3 45  # valid
   1:2:3:45  # valid

   1..2.3.45 # invalid
   1  2 3 45 # invalid
   1:2.3 45  # invalid


The functions that can be imported from this module are:

oidsort @data

returns the OID values in @data sorted.

roidsort @data

returns the OID values in @data sorted in descending order.

oidkeysort { CALC_KEY($_) } @data

returns the elements on @array sorted by the OID keys resulting from applying them CALC_KEY.

roidkeysort { CALC_KEY($_) } @data

is similar to oidkeysort but sorts the elements in descending order.

oidsort_inplace @data
roidsort_inplace @data
oidkeysort_inplace { CALC_KEY($_) } @data
roidkeysort_inplace { CALC_KEY($_) } @data

these functions are similar respectively to oidsort, roidsort, oidsortkey and roidsortkey, but they sort the array @data in place.


Sort::Key, Sort::Key::Maker


Copyright © 2007-2009 by Salvador Fandiño <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.