Sorting Dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • archulu
    New Member
    • Mar 2007
    • 34

    Sorting Dates

    how to sort the date forms in assending or decending order.
    i.e
    I/p
    12/01/2007
    23/05/1998
    15/12/2006
    21/08/1986
    i want to input like in sorting order
    i.e 21/08/1986
    23/05/1998
    15/12/2006
    12/01/2007
    plz help to me
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    what have you tried so far?

    Comment

    • miller
      Recognized Expert Top Contributor
      • Oct 2006
      • 1086

      #3
      A technique for sorting data based off of a secondary key:



      - Miller

      Comment

      • docsnyder
        New Member
        • Dec 2006
        • 88

        #4
        @archulu

        Try this:
        Code:
        @dates = (
          "12/01/2007",
          "23/05/1998",
          "15/12/2006",
          "05/12/2006",
          "21/08/1986",
        );
        
        @dates = map { $_->[0] } sort(map { [ $_, reverse(split('/', $_)) ] } @dates);
        
        map { print $_."\n" } @dates;
        Greetz, Doc

        Comment

        Working...