sort an array

  • having made array (iarray) from an ASCII file, can I now sort the items on character 34 to 40, then 5 to 7?


    • Rick McGuire
      Rick McGuire

      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.