Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I having a problem sorting file. I need to sort by first and last field. I am wondering if the problem is that the first field is alphanumeric? if you see last filed 17 comes before Thanks for any suggestions or help

require Text::CSV_XS; use File::DosGlob 'glob'; use Text::CSV_XS; #use strict; use warnings; #use Carp; open (IN,"EIS TR2.CSV"); open(OUT ,">EISTR2.NEW.csv") || die("cant open out"); while (defined($line = <DATA>)){ chomp($line); @fields =split( /,/, $line ); #$newLine=$fields[0-44]; $fields[44] =~s/^"00/"/g; $result = join (",", @fields); push (@row,$result); } foreach my $rows ( sort { $a->[0] <=> $b->[0] || $a->[44] <=> + $b->[44] } @row ) { print OUT "$rows\n"; } exit; close(OUT); close(IN); __DATA__ "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"45669NAA4" +,"45669NAA4","INDYMAC MB 07-AR-CL1A","SEL",(5411000),(4468053.82),55. +25000,2485584.23,0.00,2485584.23,1.000000,2485584.23,"9309-IN477","93 +83","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0. +00,,"US45669NAA46",55.25000,55.25000,2485584.23,"USD",,,,"INDYMAC MB +07-AR-CL1A",,,"SEL","Sell Trade",,"USD","11" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"43741BAA7" +,"43741BAA7","HMBT 2007- 2007--CL11","XSL",12000000,8306632.44,73.250 +00,(6113135.15),0.00,(6113135.15),1.000000,(6113135.15),"9309-IO584", +"7256","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC.", +,,0.00,,"US43741BAA70",73.25000,73.25000,(6113135.15),"USD",,,,"HMBT +2007- 2007--CL11",,,"XSL","Cancel Sell Trade",,"USD","12" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"43741BAA7" +,"43741BAA7","HMBT 2007- 2007--CL11","SEL",(12000000),(8285497.44),73 +.25000,6097518.88,0.00,6097518.88,1.000000,6097518.88,"9309-IO584","7 +256","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC.",,, +0.00,,"US43741BAA70",73.25000,73.25000,6097518.88,"USD",,,,"HMBT 2007 +- 2007--CL11",,,"SEL","Sell Trade",,"USD","13" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"86360BAL2" +,"86360BAL2","SARM 2006- 2006--CL6A","XSL",8790285,6025840.40,73.5000 +0,(4479475.85),0.00,(4479475.85),1.000000,(4479475.85),"9309-IN357"," +9383","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,, +0.00,,"US86360BAL27",73.50000,73.50000,(4479475.85),"USD",,,,"SARM 20 +06- 2006--CL6A",,,"XSL","Cancel Sell Trade",,"USD","14" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"86360BAL2" +,"86360BAL2","SARM 2006- 2006--CL6A","SEL",(8790285),(6025840.40),73. +50000,4451737.91,0.00,4451737.91,1.000000,4451737.91,"9309-IN357","93 +83","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0. +00,,"US86360BAL27",73.50000,73.50000,4451737.91,"USD",,,,"SARM 2006- +2006--CL6A",,,"SEL","Sell Trade",,"USD","15" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"32053BAB0" +,"32053BAB0","FIRST HORI 2007--CL1A","XSL",15000000,9625272,54.25000, +(5259596.33),0.00,(5259596.33),1.000000,(5259596.33),"9309-IM262","93 +83","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0. +00,,"US32053BAB09",54.25000,54.25000,(5259596.33),"USD",,,,"FIRST HOR +I 2007--CL1A",,,"XSL","Cancel Sell Trade",,"USD","16" "737EP0","CANYON CBMF",Dec-07-2009,Nov-05-2009,Nov-24-2009,"32053BAB0" +,"32053BAB0","FIRST HORI 2007--CL1A","SEL",(15000000),(9579529.95),54 +.25000,5234556.97,0.00,5234556.97,1.000000,5234556.97,"9309-IM262","9 +383","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0 +.00,,"US32053BAB09",54.25000,54.25000,5234556.97,"USD",,,,"FIRST HORI + 2007--CL1A",,,"SEL","Sell Trade",,"USD","17" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JGB4" +,"05532JGB4","BCAP LLC 2 09-RR-CL14","XSL",374094,374094,47.31038,(17 +8690.48),0.00,(178690.48),1.000000,(178690.48),"9331-IB374","0973","U +SD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,,4 +7.31038,47.31038,(178690.48),"USD",,,,"BCAP LLC 2 09-RR-CL14",,,"XSL" +,"Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBN3" +,"05532JBN3","BCAP 2009- 09-RR-CL10","XSL",674957,674957,98.00000,(66 +4017.07),0.00,(664017.07),1.000000,(664017.07),"9331-IB632","0973","U +SD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,"U +S05532JBN37",98.00000,98.00000,(664017.07),"USD",,,,"BCAP 2009- 09-RR +-CL10",,,"XSL","Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JCE2" +,"05532JCE2","BCAP LLC 2 09-RR-CL14","XSL",748172,748172,47.31038,(73 +6045.38),0.00,(736045.38),1.000000,(736045.38),"9331-IB802","0973","U +SD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,,4 +7.31038,47.31038,(736045.38),"USD",,,,"BCAP LLC 2 09-RR-CL14",,,"XSL" +,"Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JCA0" +,"05532JCA0","BCAP LLC 2 09-RR-CL13","XSL",2870283,2870283,98.00000,( +2823760.50),0.00,(2823760.50),1.000000,(2823760.50),"9331-IB354","097 +3","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.0 +0,,,98.00000,98.00000,(2823760.50),"USD",,,,"BCAP LLC 2 09-RR-CL13",, +,"XSL","Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBA1" +,"05532JBA1","BCAP LLC 2 09-RR-CL7A","XSL",794212,794212,98.00000,(78 +1339.15),0.00,(781339.15),1.000000,(781339.15),"9331-IB607","0973","U +SD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,,9 +8.00000,98.00000,(781339.15),"USD",,,,"BCAP LLC 2 09-RR-CL7A",,,"XSL" +,"Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBJ2" +,"05532JBJ2","BCAP LLC 2 09-RR-CL9A","XSL",1057751,1057751,98.00000,( +1040606.62),0.00,(1040606.62),1.000000,(1040606.62),"9331-IB708","097 +3","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.0 +0,,,98.00000,98.00000,(1040606.62),"USD",,,,"BCAP LLC 2 09-RR-CL9A",, +,"XSL","Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBW3" +,"05532JBW3","BCAP LLC 2 09-RR-CL12","XSL",1374994,1374994,98.50000,( +1359582.61),0.00,(1359582.61),1.000000,(1359582.61),"9331-IB579","097 +3","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.0 +0,,,98.50000,98.50000,(1359582.61),"USD",,,,"BCAP LLC 2 09-RR-CL12",, +,"XSL","Cancel Sell Trade",,"USD","2" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JGB4" +,"05532JGB4","BCAP LLC 2 09-RR-CL14","SEL",(374094),(374094),47.31038 +,178685.52,0.00,178685.52,1.000000,178685.52,"9331-IB374","0973","USD +","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,,47. +31038,47.31038,178685.52,"USD",,,,"BCAP LLC 2 09-RR-CL14",,,"SEL","Se +ll Trade",,"USD","3" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JCE2" +,"05532JCE2","BCAP LLC 2 09-RR-CL14","SEL",(748172),(747212.10),47.31 +038,736044.63,0.00,736044.63,1.000000,736044.63,"9331-IB802","0973"," +USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,, +47.31038,47.31038,736044.63,"USD",,,,"BCAP LLC 2 09-RR-CL14",,,"SEL", +"Sell Trade",,"USD","3" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JCA0" +,"05532JCA0","BCAP LLC 2 09-RR-CL13","SEL",(2870283),(2737889.47),98. +00000,2693512.85,0.00,2693512.85,1.000000,2693512.85,"9331-IB354","09 +73","USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0. +00,,,98.00000,98.00000,2693512.85,"USD",,,,"BCAP LLC 2 09-RR-CL13",,, +"SEL","Sell Trade",,"USD","3" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBA1" +,"05532JBA1","BCAP LLC 2 09-RR-CL7A","SEL",(794212),(776543.39),98.00 +000,763956.91,0.00,763956.91,1.000000,763956.91,"9331-IB607","0973"," +USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,,, +98.00000,98.00000,763956.91,"USD",,,,"BCAP LLC 2 09-RR-CL7A",,,"SEL", +"Sell Trade",,"USD","3" "737EP0","CANYON CBMF",Dec-07-2009,Nov-27-2009,Nov-27-2009,"05532JBN3" +,"05532JBN3","BCAP 2009- 09-RR-CL10","SEL",(674957),(634736.10),98.00 +000,624448.09,0.00,624448.09,1.000000,624448.09,"9331-IB632","0973"," +USD","Margin","SECURITY",0.00,"DEBT","BARCLAYS CAPITAL INC",,,0.00,," +US05532JBN37",98.00000,98.00000,624448.09,"USD",,,,"BCAP 2009- 09-RR- +CL10",,,"SEL","Sell Trade",,"USD","3"

In reply to Sorting help by mmittiga17

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found