sort an array

Developers
2007-12-19
2012-08-14
  • having made array (iarray) from an ASCII file, can I now sort the items on character 34 to 40, then 5 to 7?

    --Gary

     
    • Rick McGuire
      Rick McGuire
      2007-12-19

      This requires the 3.2.0 release. To sort on particular columns you use either sortWith or stableSortWith to perform the sorting. stableSortWith() requires more memory than sortWith() but will preserve the order of the first sort operation.

      a~sortWith(.ColumnComparator~new(34, 40))
      a~stableSortWith(.ColumnComparator~new(5, 7))

      Will perform a pair of sorts on the different substrings of the array elements.