I agree. Use any good sorting algorithm. And regarding the ubiquitous advice against comparing floating point numbers: they are only approximations to real numbers, and most real numbers are not represented exactly as floating point numbers. Therefore, two floating point approximations to the same real number may be different, depending on how they are computed. But in the case of sorting, you actually are comparing for order, not for equality, and about the only reasonable assumption that you can make is that the floating point numbers represent exact real numbers.
Dave On Oct 18, 6:45 am, xyombie <[email protected]> wrote: > On a single threaded architecture, I would use the quick > sort:http://en.wikipedia.org/wiki/Quick_sort > > On a parallel architecture, I would use Parallel Sorting by Regular > Sampling:https://agora.cs.illinois.edu/download/attachments/24348363/Sort+Para... > > In the case of floating point numbers, usually you hear that you don't > want to directly compare floating point numbers. For example: > > double d1 = 5.0, d2 = 15.0; > d2 = d2 / 3.0 > if(d1==d2) ... > > In this case, sometimes d1 & d2 might actually be different due to > floating point error. > > However, in the case of sorting, I don't believe you need to worry > about this issue. If d2 was 4.99999, then sorting would simply put > 4.99999 before 5.0. > > On Oct 18, 5:00 am, shoban <[email protected]> wrote: > > > > > How will you sort 1 million floating point numbers?- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
