This isn't Sketchup's doing.
The 'sort' algorithm in Ruby does a straightforward alphanumeric sort of the 'words'.
It depends on ASCII code numbers etc...
So punctuation (! # etc), then numbers , then some punctuation (<> etc), then uppercase letters, then some other punctuation ([] etc) and then lowercase letters etc.
Paste this in the Ruby Console to see what I mean:
["zebra","Zebra2","456","123","ABC","[xyz]","[abc]","abc","<abc>","#1"].sort
The 'bracketry' around the material names is to do with how they have been created/imported etc - read the Help section on this...
You could use the 'display_name' [what's show in the Materials Browser] in the sorted list and then have a 'look up table' that uses the materials' 'display_name' against the actual Sketchup 'name'... BUT that some extra coding that RickW needs to do to his script.
Why not PM Rick and explain the issues...
Windowizer4 is a 'commercial script' - therefore posting too much of its code is 'not on' - I even worried about that one line tweak a gave you !