copied your data into 900.txt ... ran sort -t "|" -d -k 4 900.txt after removing the first line and got this ...
2013-05-13T00:52:31.672-04:00|1|44|15277105-NA-NA||Common Stock|DOMESHR||Common Stock|CYRO AB
2013-05-14T00:52:31.662-04:00|1|4|15277105-NA-YEN||Common Stick|ESHR||Common Stock|CYRO AB
2013-05-16T00:52:31.662-04:00|12|3|15277105-NA-YEN||Common Stick|ESHR||Common Stock|CYRO ABLatest
2013-05-14T00:52:31.672-04:00|1|45|16111278-TSX-NA||Common Stk|ESQHR||Common Stock|STANDARD REGISTER CO
2013-05-15T00:52:31.672-04:00|1|40|39693766-NA-NA||Common Stick|ESHR||Common Stock|HS AG
2013-05-10T00:52:31.672-04:00|1|5|39693766-NYSE-EUR||Common HSAGStick|ESHR||Common Stock|HS AG
Thanks.
I just wanted that the 4th column rbcid value should be sorted in such a way that all like ones are in sequence no matter what the values are.
Like rbcid value starting with 15277105 should be in a order (3 in all) one after another irrespective of the values it has. All like ones in a order.
I tried this and it worked for me. This could be a lengthy process but works.
tail +2 900.txt > 901.txt
awk -F"|" '{printf("%s,%d\n",NR,$4) }' 901.txt >902.txt
sort -t"," -nrk2,2 902.txt >903.txt
head -1 900.txt
while read LINE
do
linenr=$(echo $LINE | cut -d"," -f 1)
awk -v lnr=$linenr '(NR==lnr) {print}' 901.txt
done <903.txt
To explain the logic, the 4th field with only numeric portion is extracted into a separate file 902.txt and it is printed along with a line number. Then the data is sorted on the second field in 902.txt. The first field gives the re-ordered line numbers. Then this re-ordered line number is used to compare with original file and print corresponding row. For each line in 902.txt, the original file is read completely and only the matching line number is printed.