I like this sentiment. Basically, you iterate the array until you find the first unsorted element (in this case it's the first item), and then trigger the sort. If you don't want to do that, then use a flag that is set any time the array is sorted. Some sanity could be gained if all items were only ever added to either the top XOR the bottom of the array.
My final thought is perhaps you should use a sort like the 'Insertion Sort'. It will, on the average cases, deal with already sorted arrays at O(N).
Good luck!
Kurt
In reply to Re^2: Fast way to check if a sort was doen
by whereiskurt
in thread Fast way to check if a sort was doen
by Outaspace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |