Bubble sorts can be extremely fast in certain cases. if the data is mostly sorted, they might actually be the fastest.
Bubble sort is quite fast when you only have a few items to sort. I did some timing of bubble vs selection vs recursive merge sort about 3 years ago; allowing for quadratic complexity in bubble and selection and nlogn complexity for merge sort, I worked out that bubble and merge are about the same speed for 2^6 (64) to 2^7 (128) members in what I was sorting, but bubble would be faster for 2^5 (32) and merge faster for 2^8 (256) members.
Joined: Oct 13, 2005
Originally posted by p paul: sort map pairs by values
Can you get all the values into an array then create a Comparator for differences between values, then sort?