How do I sort a file which has floating point numbers in asc/descending order ?
e.g.
2.1
2.10
1.1
1.2.
2.5
Thanks in advance
Zul
e.g.
2.1
2.10
1.1
1.2.
2.5
Thanks in advance
Zul
> 2.1
> 2.10
> 1.1
> 1.2.
> 2.5
This won't handle correctly 1e+6, negative numbers...
--
Stphane
sort -n your_fileQuote:> How do I sort a file which has floating point numbers in asc/descending order ?
> e.g.
> 2.1
> 2.10
> 1.1
> 1.2.
> 2.5
>> e.g.
>> 2.1
>> 2.10
>> 1.1
>> 1.2.
>> 2.5
>sort -n your_file
--
Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Well, with GNU sort it worked fine for me.Quote:> >sort -n your_file
> That does integer sort, not floating point. It will ignore everything
> after the ".".
>> That does integer sort, not floating point. It will ignore everything
>> after the ".".
>Well, with GNU sort it worked fine for me.
--
Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
ie; floating point numbers. This is a FIXED-point sortQuote:>$ sort -t. -k1n,1n -k2 << EOF
>heredoc> 2.1
>heredoc> 2.10
>heredoc> 1.1
>heredoc> 1.2.
>heredoc> 2.5
>heredoc> EOF
>1.1
>1.2.
>2.1
>2.10
>2.5
>This won't handle correctly 1e+6, negative numbers...
In all probability of course the OP used the term 'floating point'
when they meant 'fixed point' which seems to be a very common confusion
of terms.
byefornow
laura
--
alt | Madonna's done something to try to stop this war,
fan | Why don't you? Mail this interesting article
madonna | to as many people as you can;
| http://seattle.indymedia.org/front.php3?article_id=23919&group=webcast
| LOVE & PEACE!
>>$ sort -t. -k1n,1n -k2 << EOF
>>heredoc> 2.1
>>heredoc> 2.10
>>heredoc> 1.1
>>heredoc> 1.2.
>>heredoc> 2.5
>>heredoc> EOF
>>1.1
>>1.2.
>>2.1
>>2.10
>>2.5
>>This won't handle correctly 1e+6, negative numbers...
>ie; floating point numbers. This is a FIXED-point sort
>In all probability of course the OP used the term 'floating point'
>when they meant 'fixed point' which seems to be a very common confusion
>of terms.
Fixed point also implies a specified maximum number of digits before and
after the decimal point. E.g. in PL/I you might declare a variable to be
FIXED BIN(9,3), meaning 9 total bits with 3 bits of fraction, or FIXED
DEC(12,2) for 12 total digits with 2 after the decimal point. Fixed point
is typically represented internally as a scaled integer.
--
Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> >> That does integer sort, not floating point. It will ignore everything
> >> after the ".".
just using -g if available.
> e.g.
> 2.1
> 2.10
> 1.1
> 1.2.
> 2.5
Peter
--
I wish dialog boxes had a butten saying "Whatever". I hate being
forced to answer "Yes" or "No" to a question I have no opinion on
whatsoever. There ought to be a button matching my indifference.
1. Question on floating-point numbers
Give me a hand !
Does anybody know the largest floating point number and the smallest
floating-point number and the base of the floating-point number.
The fortran compiler I am using is ver. 2.1.
thanx.
2. *PATH settings should go in .profile or .kshrc?
3. How to represent floating point numbers with German format
4. $19 UnixWare and OpenServer and SN
5. Expr and floating point numbers
6. STB nVIDIA TNT 16MB Card with Solaris 8 Intel
7. Network standard for floating point numbers? [summary]
9. script to compare two floating point numbers or expressions
10. Working with floating point numbers
11. Garbage in floating point numbers?
12. uniform floating point random number generator - summary
13. Network standard for floating point numbers?