Sorting files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sadanand
    New Member
    • May 2007
    • 6

    Sorting files

    Can anyone tell me how to sort the list of files on the basis of creation time and date of file?
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Hi Sada,

    All you need is the following functions:

    perldoc stat
    perldoc -X
    perldoc sort

    [CODE=perl]
    my @sorted = sort {(stat($a))[9] <=> (stat($b))[9]} @files;
    [/CODE]

    - Miller

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by sadanand
      Can anyone tell me how to sort the list of files on the basis of creation time and date of file?

      Miller has posted the functions you can use to do this, but what do you mean by:

      "creation time and date of file"

      what is "date of file"?

      Comment

      • sadanand
        New Member
        • May 2007
        • 6

        #4
        Originally posted by KevinADC
        Miller has posted the functions you can use to do this, but what do you mean by:

        "creation time and date of file"

        what is "date of file"?
        Hi Kevin,

        what is "date of file"?

        ---->The date and the time when the file was created.

        Regards,

        Sadanand

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          OK, I gotcha now. Millers suggestion will do that for you.

          Comment

          Working...