Thread: Best sorting method to use

  1. #1
    Registered User
    Join Date
    Mar 2003

    Question Best sorting method to use

    Hi -

    What is the best sorting method (speed wise) to use to sort roughly 40,000+ objects in ascending/desceding order? Selection sort only comes to mine. Are there any others?

    What I have to do is find any duplicate numbers in a 40,000+ list. My game plan to approach this problem is ...

    1) Sort the numbers in ascending/descending order first
    2) After a sorted list is created, take the first number and compare it to every other number in that list. If a match if found, record it.
    3) Move on the next number in the list and repeat step 2. Do this until you reach the bottom of the list.

    Are there any problems with my thinking or is there something I can do to make more algorihim more efficent?


  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Look up quick sort, it is arguably the best sort out there. Do a search on google or on this board and you'll find lots of examples on it.

    Once your items are sorted, you don't need to look at every item to see if there is a duplicate. You only need to look at the next item. If the next item doesn't match, then it is unique.
    Last edited by PJYelton; 03-11-2003 at 07:47 PM.

  3. #3
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001



    my favorite thing thus found in the standard
    "He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson

  4. #4
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    quicksort, non-recursive I feel would help...

    if you use the recursive version on such a large pile, you might have speed problems.

    btw, the sort is in the standard library

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. best sorting method to sort half end of array
    By nitinmhetre in forum C Programming
    Replies: 2
    Last Post: 01-11-2007, 12:18 PM
  2. Name of sorting method
    By noodles in forum Tech Board
    Replies: 6
    Last Post: 10-07-2006, 01:54 AM
  3. Sorting Method
    By silicon in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2005, 10:06 PM
  4. change sorting method using polymorphism
    By Forever82 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2003, 01:21 PM
  5. Sorting words with a fast, effincient sorting method
    By Unregistered in forum C++ Programming
    Replies: 19
    Last Post: 07-12-2002, 04:21 PM