I needed a simple sorting routine and everything I looked at got my eyes glazing over. So I came up with this.
I needed to start fans with lowest hours, so the fan pTable is loading the Fan pointer with the first index from the hour meter table and then comparing that hour meter to all other hour meters in the table. Each time it is lower or equal, it adds one to the SortOrder_nTable at the current index of the Sort Index. The HmIndex is used to iterate through all 10 elements of the Hm table comparing the same element from the same table. The next iteration is with element 2 of the Hm table and each complet iteration sum (now in the sort table) is then subtracted from the total number of indexes and put back in that same sort table index. This is the sorted index ranking for that index. When all the iterations are done, the sort table has a collection of rankings that are related to the hour meter table index for the sorted order of each hour meter element in the hour meter table.
This could be taken further to put these indexes in order from 1-10 in another table if needed. Also I suspect one could use this to sort alpha by using ascii code to sort the characters.
Test1.Archive.D03062017.T121823.zip (4.6 KB)