had to return to a old app I had build in Classic ASP and do a few changes, however one bit is stumping me.
I have a string such as:
theTimings = "12:00-14:30,18:00-22:30,07:30-10:30"
I am turning this into an Array using
timingsArray=Split(theTimings,",")
However I need to sort this Array so the earliest times appear first, i.e.
07:30-10:30,12:00-14:30,18:00-22:30
Anyone got any idea how to do this?
You want to sort an array, Classic VBScript ASP does not offer that. So you got 4 options: Use JScript, gather from .NET, convert the array to a dictionary and sort there or “roll your own algorithm” (a.k.a. find something on the net).
Sorry, I don’t know which one would be optimal or faster, but if you go with VBScript, I advise using quick sort. Here’s an implementation of it that’s applicable with strings that I’ve adapted from somewhere:
And as a bonus, this is my “print_array”, which I want to evolve into a fully working “print_r” someday: