Jump to content


Photo

sorting UNixdate


  • Please log in to reply
3 replies to this topic

#1 DieSucker

DieSucker
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 27 June 2006 - 04:27 AM

ok so say that I got a txt file with a bunch of lines like the one below

Record[0]=CTF-BT-Athletic1000    1955    trs|McN                      1150150175CTF-BT-Lego    1908    Hazen_Blazen                 1150285451CTF-BT-w00tw00t_fix    1964    jumper                       1150200327CTF-BT-andACTION    1989    trs|DieSucker                1150749074
and then I am spliting each line first at the "=" so then i have just


CTF-BT-Athletic1000    1955    trs|McN                      1150150175CTF-BT-Lego    1908    Hazen_Blazen                 1150285451CTF-BT-w00tw00t_fix    1964    jumper                       1150200327CTF-BT-andACTION    1989    trs|DieSucker                1150749074
then spliting it at "\t" so basically i end up with
CTF-BT-Athletic1000
1955
trs|MCN
1150150175
CTF-BT-Lego
1908
Hazen_Blazen
1150285451


so is there anyway to organize all his by unixdate code?

#2 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 27 June 2006 - 11:58 AM

what do you mean by organize all this by unixdate code?

Life's too short for arguing.

#3 DieSucker

DieSucker
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 28 June 2006 - 05:21 PM

[!--quoteo(post=388464:date=Jun 27 2006, 06:58 AM:name=hvle)--][div class=\'quotetop\']QUOTE(hvle @ Jun 27 2006, 06:58 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
what do you mean by organize all this by unixdate code?
[/quote]
well organize by date, each unixdate code has a date associated with it ie 6/26/2006(date(mdY))
so is there anyway to get the most recent dates on top of the list and later ones towards the bottom

#4 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 29 June 2006 - 05:22 PM

ok,

first, you need to read them all into an array. You know that a 4 lines will be 1 row, so it'll be easy problem.

then sort the array with ksort, specify the key you wanted to sort. If you specify the key with timestamp, it'll sort by timestamp, and so on.

Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users