Help with sort data based on descending order problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with sort data based on descending order problem
# 1  
Old 06-06-2011
Help with sort data based on descending order problem

Input file
Code:
9.99331e-13
8.98451e-65
9.98418e-34
7.98319e-08
365592
111669
74942.9
0

Desired output
Code:
365592
111669
74942.9
7.98319e-08
1.99331e-13
6.98418e-34
9.98451e-65
0

Command try
Code:
sort -nrk1 input_file
365592
111669
74942.9
9.98451e-65
7.98319e-08
6.98418e-34
1.99331e-13
0

Thanks for any advice to get my desired output.
The command I try is fail to get desired output when the input file contain "e"
# 2  
Old 06-06-2011
could this help you ?
Code:
#!/usr/bin/perl

@array=<DATA>;
@sorted=sort{$b <=> $a}@array;
print map("$_",@sorted);

__DATA__
9.99331e-13
8.98451e-65
9.98418e-34
7.98319e-08
365592
111669
74942.9
0

This User Gave Thanks to pravin27 For This Post:
# 3  
Old 06-06-2011
Hi.

Briefly, for input data2:
Code:
9.99331e-13
8.98451e-65
9.98418e-34
7.98319e-08
365592
111669
74942.9
0

Code:
sort -gr data2
365592
111669
74942.9
7.98319e-08
9.99331e-13
9.98418e-34
8.98451e-65
0

with:
Code:
sort (GNU coreutils) 6.10

See man sort for details ... cheers, drl

PS Probably a typo exists in desired output, 1 <- 9 for 9.99331e-13
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to sort list of directories in descending order in perl?

Hi, I have a problem . I have few directories like inpTDT_1, inpTDT_2, inpTDT_3 and so on inside HOME directory . In one of my perl script (which is in my HOME), the above directories like inpTDT_1, inpTDT_2, inpTDT_3 are sorting out in an order So I wanted to sort all the inpTDT_1, inpTDT_2,... (1 Reply)
Discussion started by: venkatesh
1 Replies

2. UNIX for Dummies Questions & Answers

Sorting a file in descending order when you have 10e- values

Hi, I am trying to sort the following file in descending order of its fourth column. 2 1 363828 -2.423225e-03 3 1 363828 4.132763e-03 3 2 363828 8.150133e-03 4 1 363828 4.126890e-03 I use sort -k4,4g -r input.txt > output.txt ... (1 Reply)
Discussion started by: evelibertine
1 Replies

3. Shell Programming and Scripting

script for remove descending order number

hi all i want to remove some descending order number example : 1 100 200 135.00 Gk_wirs 1 1 100 200 136.00 Gk_wirs 50 1 110 210 138.00 Gk_wirs 60 1 100 200 136.00 Gk_wirs 57 ----> how to remove... (6 Replies)
Discussion started by: nithyanandan
6 Replies

4. UNIX for Dummies Questions & Answers

How to sort a column based on numerical ascending order if it includes e-10?

I have a column of numbers in the following format: 1.722e-05 2.018e-05 2.548e-05 2.747e-05 7.897e-05 4.016e-05 4.613e-05 4.613e-05 5.151e-05 5.151e-05 5.151e-05 6.1e-05 6.254e-05 7.04e-05 7.12e-05 7.12e-05 (6 Replies)
Discussion started by: evelibertine
6 Replies

5. UNIX for Dummies Questions & Answers

how to list descending order

Hi, I want to short descending all the files according to their size.Please help me.. (1 Reply)
Discussion started by: jyotidas
1 Replies

6. Shell Programming and Scripting

ascending and descending sort

Hi I have a problem with sort command : sort -nk 1.28,1.34 file | sort -nrk 1.27 file | sort -nk 1.22,1.25 file |sort -nk 1.13,1.21 file | sort -nk 1.9,1.12 file | sort -nk 1.1,1.8 file This is the input file 0000000100010000000200004090317003 0000000100010000000230001020592002... (3 Replies)
Discussion started by: Fafa
3 Replies

7. UNIX for Dummies Questions & Answers

Help - Find command with list of files modified descending Order

Hi, I would like to know the command to get the files order in descending order with "FIND" command. Appreciate your help Thanks (4 Replies)
Discussion started by: TonySolarisAdmi
4 Replies

8. Shell Programming and Scripting

Ascending & Descending order numbers

Dear All, I have below attached file in which i have many nos, i want the last ascending order nos. The brief description is given below. File 315 381 432 315 381 432 315 381 432 315 381 432 315 381 432 (6 Replies)
Discussion started by: pravani1
6 Replies

9. Shell Programming and Scripting

Sort Descending

HI, i want to sort values in descending order and get the column no.s of the sorted value. my data will look like: subject 1 2 3 4 5 bob 78 45 89 99 54 i want the score to be sorted in descending and get the corresponding subject sorted in the output. Please help me with gawk or ??... (1 Reply)
Discussion started by: saint2006
1 Replies

10. UNIX for Dummies Questions & Answers

how to see disk usage in descending order

What is the command used by sysadmin to see the disk used by the users in descending order of their disk usage? (8 Replies)
Discussion started by: asutoshch
8 Replies
Login or Register to Ask a Question