@Tim_Parnell,
Yes, that’s where I started (naturally).
Unfortunately I came away with the understanding that what I have shown (above) would do what I’m wanting… and it does not. I read the docs and evidently do not understand them correctly.
@TimStreater,
I tried that as well. Also doesn’t sort the fileSize array in the same order as the fileList array.
So a key takeaway is that the base array is the one doing the sort. Both arrays are being sorted every time.
arsNames.SortWith(ariSizes) will sort the sizes array the same way the names array gets sorted.
You must always keep these in sync. The first thing your original post does is separate the association between the names and the sizes by sorting the names array by itself.
Ah… I get it now.
Once the association is made the associated arrays will then be sorted in the order of the base array. So I make the associations between whatever arrays need to be connected and then sort the original array, and the rest will follow.
I thought the same thing that the OP did. I get it now, but that is really unintuitive. In most cases you would want a sorted Index of the original array so that you can then refer back to the original array by index. It doesn’t do any good to have a sorted index if the array it was based off of is now also sorted. I can work around it, but that is an odd implementation. So much to love about Xojo, but this one doesn’t make the list.
I can’t say as I agree. I have two arrays where the item with index j in one array belongs with the item with index j in the other array. I want to be able to sort both according to some criterion that relates to one on the arrays, and then still have the association between items in the two arrays with the same index.