Thread: Sorting Without an Array

  1. #16
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The fundamentals of your program are broken anyway. No point in having input and output working if you read the data, munge it, and then write it out.

    When you tell people to get in a line, in order of age, those people don't assign their ages to someone else.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  2. #17
    Registered User
    Join Date
    Feb 2013
    Posts
    22
    i'm trying not to use linked lists...i don't understand it!

  3. #18
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You can't sort records in memory unless you actually have more than one of them in memory.
    You can store the records in an array, a list, a binary tree, a skip-list, or ..... but one way another you have to learn about the data structure that you choose to use. Generally an array is about the simplest choice, but with an unknown number of records, one way or another you are going to have to learn dynamic memory allocation i.e. malloc & free.

    Another option is disk-based sorting, but even then you need to have at least two records in memory at once in order to compare them, and of course you either have to modify the existing file, or write it out to a new file.

    If you still find none of that appealing, then I suggest you switch to C++, where this kind of thing is a piece of cake. You either learn how to use the language you've chosen, or you don't.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding nodes to an array at the top & array sorting
    By Wolf` in forum C++ Programming
    Replies: 1
    Last Post: 06-25-2010, 12:48 PM
  2. Replies: 9
    Last Post: 04-07-2010, 10:03 PM
  3. Q sorting a 2D array
    By avi2886 in forum C Programming
    Replies: 4
    Last Post: 05-27-2009, 02:34 PM
  4. Array Sorting ???
    By Takis_ in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2008, 10:38 AM
  5. Sorting an array
    By cashmerelc in forum C Programming
    Replies: 2
    Last Post: 12-05-2007, 01:57 AM