HW6 Getting Sort to recognize scientific notation

5 views
Skip to first unread message

Malcolm Greaves

unread,
Mar 28, 2012, 1:10:14 AM3/28/12
to machine-learning-with-large-d...@googlegroups.com
Hi all,

Does anyone know how to get (unix) sort to recognize scientific notation? I have a problem where sort thinks 3.66E-4 is larger than 0.461242.

- Malcolm

Malcolm Greaves

unread,
Mar 28, 2012, 1:12:16 AM3/28/12
to machine-learning-with-large-d...@googlegroups.com
Of course, I forgot to check the man pages first =P. If anyone's interested, use the -g flag  (replace -n) to do numeric sorting with scientific notation too.

- Malcolm

Phil Brown

unread,
Mar 28, 2012, 6:48:38 AM3/28/12
to machine-learning-with-large-d...@googlegroups.com
Thanks for the tip!  I had been working around this by formatting my output to 8 places after the decimal using
String.format("%.8f", pageRank)

Yilun Cui

unread,
Mar 28, 2012, 1:11:16 AM3/28/12
to machine-learning-with-large-d...@googlegroups.com
the trick is to have java not print it in scientific notation

Malcolm Greaves

unread,
Mar 28, 2012, 12:34:58 PM3/28/12
to machine-learning-with-large-d...@googlegroups.com

Or the -g flag.......

Reply all
Reply to author
Forward
0 new messages