Is it possible to sort an array based on the 2nd (or n th column)
A roundabout way would be rewriting the file, making the 2nd column into the 1st column, then sorting it and then writing it back the way the columns need to be placed, although I was hoping there was an easier way
Sorting it based on 1st column would be
filarray_Unsorted =ArrayFileget(File_Unsorted)
ArraySort(filarray_Unsorted, @ASCENDING, 0, 0, ArrInfo(filarray_Unsorted,1)-1)
ArrayFileput(File_Sorted, filarray_Unsorted)
Simple enough. To sort on the second column
ArraySort(filarray_Unsorted, @ASCENDING, 1)
Quote from: td on December 29, 2014, 02:19:34 PM
Simple enough. To sort on the second column
ArraySort(filarray_Unsorted, @ASCENDING, 1)
I get Error 1830 - Sort column is out of range on ArraySort(filarray_Unsorted, @ASCENDING, 1)
Your array does not have 2 dimensions... I should have added that if your file has delimited columns then try using ArrayFilePutCsv to create a 2 dimensional array. If your file has fixed length records and fixed length fields with a single key type you can just use BinarySort. Full documentation for ArraySort, ArrayFilePutCsv and BinarySort can be found in the help file.