First off - the language I'm using is VBScript, used with Windows Scripting Host. I don't really have the option of changing that and using something else.
At this point, I have a number of records with multiple fields, read in from a file. I want to print them out in a number of orderings (first, in alphabetical order; second, grouped by location and then sorted alphabetically within locations; etc.). The records are stored in an ArrayList.
If I was using Visual Basic rather than VBScript, I know that I could create classes which implemented the iComparer interface, and then call the Sort function of the ArrayList with an object of the appropriate class when I wanted to sort in that order (use the Alphabetical object for the first sort, the LocationThenAlphabetical object for the second sort, etc.)
However, I have been going crazy trying to find a way to do that or anything similar in VBScript, the language I actually have available to work with. I've Googled endless combinations of "VBScript", "ArrayList", "sort", "custom sort", "comparison", "custom comparison", "implements", "interface" - but whenever I find results relevant for VBScript, they aren't about how to do a custom sort, and whenever I find results relevant to custom sorting, they aren't applicable to VBScript, even if that was clearly specified in my search.
I would rather do this the right way, if that's possible. If it's simply not possible to do a custom sort in VBScript, I can see a possible work-around, but it would add a lot of complexity and use a lot more memory than I think a custom sort would do.