Does anyone out there know of a way to sort dates into order? I have a comma delimited array that contains a date ie;"11 Oct 2001" as the first part of the array. It is being read in from a text file and when I add new items to the array I want to resort them into date order before writing them back to the file.

Thanks
TW.

    Trevor,

    Since the strings you are reading in cannot be sorted (The month name screws everything) You are probably going to have to convert them to dates. You may have to then convert the days into YYYYMMDD strings. Don't know, I haven't played much with asort or sort. Check out the manual here:
    http://www.php.net/manual/en/ref.array.php

    Cal
    Cal Evans
    - Senior Internet Dreamer
    - Techno-Mage
    - Last of the great Internet Burma-Shave poets.
    http://www.calevans.com
    *

      Thanks cal,
      I had a good long thought about this and in the end took a timestamp of the date before the original save to the text file - appended this to the start of the line.

      when I now read in the text file into an array, the timestamp (which is now the first part of the array)can be sorted into numerical order using the sort function.

      "we live and learn"
      TW

        Write a Reply...