Thread: Sorting Integer Arrays

  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
    Chappell Hill, Texas
    Posts
    2,332
    What have you tried? Where are you stuck?
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    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

  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
    Chappell Hill, Texas
    Posts
    2,332
    Show your code that is a basic c program shell, with an initialized array with 10 elements.
    Mainframe assembler programmer by trade. C coder when I can.

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    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.

  7. #7
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    It's take a few more than 10 values to get a picture of what is the fastest. Bubble sort is a good option.
    Mainframe assembler programmer by trade. C coder when I can.

  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, 04:37 PM
  2. Question sorting character arrays: C programming
    By NeoSigma in forum C Programming
    Replies: 3
    Last Post: 05-23-2003, 09:28 PM
  3. Sorting arrays
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 06-19-2002, 02:43 PM
  4. Help with sorting arrays
    By Silence in forum C Programming
    Replies: 5
    Last Post: 05-17-2002, 10: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