sort the windows first