Thread: Any intelligent way sorting an array?

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    11

    Any intelligent way sorting an array?

    As I know, there is one thing called bubble sort(sinking sort). i.e.

    successive pairs of elements are compared
    - if increasing order (or identical), no change
    - if decreasing order, elements exchanged
    repeat these steps for every element

    However, (I think) swaping the values of two elements may not be efficient enough, so I try to create an array to record the index of the acsending order array.

    So, this is only my thought, can someone give me a more intelligent way to sort an array and record it down?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Check out the uses of qsort() in all these posts
    http://cboard.cprogramming.com/searc...searchid=18071
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-31-2009, 12:34 PM
  2. two dimensional array sorting in C/C++
    By George2 in forum C Programming
    Replies: 16
    Last Post: 11-19-2006, 03:17 AM
  3. Sorting an array
    By OnionKnight in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2005, 03:31 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. sorting array efficiently...can't find the error
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 04-09-2002, 02:32 PM