Of course, what I’m looking for is the natural sort order of _1 through _12.
Does anyone have a natural sort order method / extension? I thought that there was one in Joe Strout’s old StringUtil package, but I can’t find it now.
For this one case, I’d extract the numbers of each item into an Integer array, then use SortWith. For more flexibility, I’d use a regex to find and pad the numbers in the string and put those into another array, then use SortWith. Using your example:
Original SortArray
myfile_1 myfile_0000000001
myfile_10 myfile_0000000010
myfile_11 myfile_0000000011