Sorting Integer Arrays

This is a discussion on Sorting Integer Arrays within the C Programming forums, part of the General Programming Boards category; Hi, I'm trying to sort an array of integers. I'm not sure how to sort numbers from lowest to highest. ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    6

    Sorting Integer Arrays

    Hi, I'm trying to sort an array of integers. I'm not sure how to sort numbers from lowest to highest. Any ideas?

    Thanks- Bunko

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    What have you tried? Where are you stuck?
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    What kind of sort? Bubble sort, cocktail sort, comb sort, gnome sort, selection sort, insertion sort, shell sort, binary tree sort , library sort, merge sort, heap sort, smoth sort, quick sort ?

    http://en.wikipedia.org/wiki/Sorting_algorithm
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    6
    It's a small integer array of ten elements. I'm not sure which sorting algorithm would be the most efficient for such a small array. All I need to do is take those ten numbers and sort them from lowest to highest. Pathetically to say, I'm lost.

    Thanks - Bunko

  5. #5
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Show your code that is a basic c program shell, with an initialized array with 10 elements.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    for such a small array I would recommend bubble sort, its the easiest to impliment. Its not usually the fastest but with so few numbers to sort I doubt it will make any difference unless the instructor specifically told you to find the fastest method.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  7. #7
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    It's take a few more than 10 values to get a picture of what is the fastest. Bubble sort is a good option.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  8. #8
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    I have nothing else to add but this...

    http://www.sorting-algorithms.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help sorting arrays
    By Flyer in forum C++ Programming
    Replies: 4
    Last Post: 07-12-2003, 05:37 PM
  2. Question sorting character arrays: C programming
    By NeoSigma in forum C Programming
    Replies: 3
    Last Post: 05-23-2003, 10:28 PM
  3. Sorting arrays
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 06-19-2002, 03:43 PM
  4. Help with sorting arrays
    By Silence in forum C Programming
    Replies: 5
    Last Post: 05-17-2002, 11:05 AM
  5. Sorting 2 arrays of different type
    By GaGi in forum C++ Programming
    Replies: 3
    Last Post: 04-04-2002, 10:33 AM

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