Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data that just wont sort 1

Status
Not open for further replies.

RaoulZa

Technical User
Sep 5, 2002
14
GB
"10790","F3","F","","00:00","23:59",
"10800A","F3","F","","00:00","23:59"
"10800","F2","F","","00:00","23:59",
"1080","F1","F","","00:00","23:59","
"10810","F3","F","","00:00","23:59",
"10820","G1","G","","00:00","23:59",
"10830","F3","F","","00:00","23:59",
"10840","F3","F","","00:00","23:59",
"10845","C1","C","","00:00","23:59",
"10846","C2","C","","00:00","23:59",

The above data is 'sorted' according to the first field. I have another file which i am trying to match using a field keying on this first field. The problem arises in the way the data above is laid out.

It shows 10800A
10800
1080

when using the same sort option ( just a basic sort ) the other file produces 1080
10800
10800A

which is what i want them both to say.

Has anybody any idea on switching the lines about using sort or any other command?

 
use:
sort -n -t\" +1 filename
------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.
 
that was brilliant

if i wanted to sort on the third field do i substitute a 3 for the 1?

Za
 
ja ------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.
 
sort -n -t\" +3 m3a.txt > m3b

thats not doing it for me ( so to speak )

*sobs helplessly as he cant quite figure it out*
 
bah it was +5 as " is the delimiter, not ','

thanks again
 
*pulls hair out*

ok this has left me with mostly the sort that I want, except that it has given me for example

11010A
11010A
11010A
11010A
11010B
11010B
11010B
11010A

does this constitute a sort on an individual column after the main sort on the field, if so hows it done?

thanks
 
i don't understand the quiestion. ------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.
 
its ok i found it - for some reason the data was sorted as you specified, but it was producing that sort of output. so where i was expecting 11010A to be before 11010B, sometimes the letters at the end seemed to be appearing randomly - as above where there are several with B on the end followed by one with A on the end.

what i wanted to know was if i could sort the individual column - the 6th character in the field - as part of the overall sort

i entered sort -n -t\" +5 -d +5.5 m3a.txt > m3b

and it seems to have solved my problem - i think - this sorts it as you explained, but where ther eis a 6th character in the field, it subsorts it according to that character.

does that make any sense? ( i have never been known for making sense )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top