How to sort an array?

This is a discussion on How to sort an array? within the C Programming forums, part of the General Programming Boards category; Hi! I'm very new on programming c and need a little help with sorting an array... I have the following ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    How to sort an array?

    Hi!

    I'm very new on programming c and need a little help with sorting an array...

    I have the following Array:

    LastBlocks[i].FileDate
    LastBlocks[i].LastBlock
    LastBlocks[i].StartCluster
    LastBlocks[i].WriteDate

    FYI: [i] counts up to max. 300

    Now I'm looking for a possibility, how to sort this array by LastBlocks[i].WriteDate?

    The content of LastBlocks[i].WriteDate is (wmjd << 16 | hour << 8 | min);
    LastBlocks[i].WriteDate contains the time/date when the entry was added to the list...

    I would like to have the newest entry first and the oldest one at the end of the array after sorting...

    Could you help my with that?

    Thanks in advance,
    Gerti

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    malloced 2d array passed to qsort
    All you need to do is change the compare function to match what you have.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Insertion Sort on Array of Structs
    By n0r3gr3tz in forum C Programming
    Replies: 3
    Last Post: 04-01-2008, 08:28 AM
  2. Using unix command line to sort random array
    By lostmyshadow in forum C Programming
    Replies: 4
    Last Post: 12-11-2007, 06:14 PM
  3. New Sort an Array of Classes
    By ajpeters in forum C++ Programming
    Replies: 11
    Last Post: 09-06-2005, 06:23 PM
  4. how to sort out an array?
    By Chobo_C++ in forum C++ Programming
    Replies: 1
    Last Post: 03-08-2004, 04:33 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM

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