eileen1017
MIS
I have a file reads something like this:
01-JAN-2007, USER=crystal
02-JAN-2007, USER=crystal
02-JAN-2007, USER=Phillips
02-JAN-2007, USER=robinson
02-JAN-2007, USER=maguilar
02-JAN-2007, USER=cshannon
I want to sort the file with username first then the date.
My script as the following:
#!/usr/bin/perl
open (DISPLAY, display.txt)||die "Can't open the file!\n";
@line=<DISPLAY>;
@line=sort(@line);
print "@line";
close(DISPLAY);
However, the results is not I wanted. My results came out like this:
01-APR-2007, USER=crystal
01-APR-2008, USER=SMSMaster
01-APR-2008, USER=aaghili
01-APR-2008, USER=crystal
01-APR-2008, USER=elemm
01-APR-2008, USER=feathers
01-APR-2008, USER=maduro
01-APR-2008, USER=maguilar
It does sort, but it seems like it sorts the date first, even though it sorts the date, it is not the kind of sort I want. How can I achieve the sort I want which will be username first and then the date? Thanks in advance for your help.
01-JAN-2007, USER=crystal
02-JAN-2007, USER=crystal
02-JAN-2007, USER=Phillips
02-JAN-2007, USER=robinson
02-JAN-2007, USER=maguilar
02-JAN-2007, USER=cshannon
I want to sort the file with username first then the date.
My script as the following:
#!/usr/bin/perl
open (DISPLAY, display.txt)||die "Can't open the file!\n";
@line=<DISPLAY>;
@line=sort(@line);
print "@line";
close(DISPLAY);
However, the results is not I wanted. My results came out like this:
01-APR-2007, USER=crystal
01-APR-2008, USER=SMSMaster
01-APR-2008, USER=aaghili
01-APR-2008, USER=crystal
01-APR-2008, USER=elemm
01-APR-2008, USER=feathers
01-APR-2008, USER=maduro
01-APR-2008, USER=maguilar
It does sort, but it seems like it sorts the date first, even though it sorts the date, it is not the kind of sort I want. How can I achieve the sort I want which will be username first and then the date? Thanks in advance for your help.