Array Sorting ???

This is a discussion on Array Sorting ??? within the C++ Programming forums, part of the General Programming Boards category; Hi to everyone...! How could i sort an array with float by decrease sorting? thanks..!...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    4

    Arrow Array Sorting ???

    Hi to everyone...! How could i sort an array with float by decrease sorting?
    thanks..!

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    if is easy be selection sort, thanks again.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,312
    #include <algorithm> and use std::sort instead of implementing a quadratic time sort like selection sort.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    keep in mind that std::sort by default sorts in ascending order (smallest to biggest). To make it sort in descending order, you have to supply a comparison function.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    thanks but i need with selection sort to do it.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So what you are actually asking is for one of us to write a selection sort for you? That's not how it works here - you write the code, we explain what's wrong, how it works etc when you ask SPECIFIC questions.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    IIRC
    Code:
    procedure selection_sort (a, first, last) :
       while last > first :
          choose highest item in a from [first, last), called max
          swap a(max) with a(last)
          decrement last
       end while
    done
    Last edited by whiteflags; 04-04-2008 at 03:58 AM.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    4
    Thanks , Perfect Gentleman...!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-31-2009, 01: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. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 10:48 AM

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