Any intelligent way sorting an array?

This is a discussion on Any intelligent way sorting an array? within the C++ Programming forums, part of the General Programming Boards category; As I know, there is one thing called bubble sort(sinking sort). i.e. successive pairs of elements are compared - if ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21