Optimized gnome sort