I wasn't able to find a way of scripting this easily and quickly, however, you can do it from : Window (Alt + w), Sort

The closest that I was able to find (quickly) for a scriptable option would require you to know what order you want the windows in, then use
Code:
 /window -z <window name> 
to order the windows.