From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder@niaid.nih.gov>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Inconsistency with sort -n?
Date: Wed, 31 Dec 2008 21:39:00 -0000 [thread overview]
Message-ID: <0105D5C1E0353146B1B222348B0411A211B41DEC@NIHMLBX02.nih.gov> (raw)
`sort -n' and `sort -g' work inconsistently with 0 and -0 if there are leading spaces. Sometimes -0 is before 0, as I would expect, and sometimes it is afterwards. Adding `-b' does not seem to help.
Is this where I should report it or should I go upstream?
In case you are wondering why I want to do this: I'm counting items in a bin so the bin from -1 to 0 and 0 to +1 are different.
Please excuse the excessive number of examples.
Happy Gregorian New Year!
- Barry
Disclaimer: Statements made herein are not made on behalf of NIAID.
________________
$ echo 0 -1 -0 1 | tr ' ' '\n' | sort -n
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e 's/^/ /' | sort -n
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' | sort -n
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' | sort -n
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -n
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' -e 's/^/ /' | sort -n
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -n
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/!s/^/ /' -e 's/^/ /' | sort -n
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sort -g
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e 's/^/ /' | sort -g
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' | sort -g
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' | sort -g
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -g
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' -e 's/^/ /' | sort -g
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -g
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/!s/^/ /' -e 's/^/ /' | sort -g
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sort -nb
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e 's/^/ /' | sort -nb
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' | sort -nb
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' | sort -nb
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -nb
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/^.$/s/^/ /' -e 's/^/ /' | sort -nb
-1
0
-0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/s/^/ /' -e 's/^/ /' | sort -nb
-1
-0
0
1
$ echo 0 -1 -0 1 | tr ' ' '\n' | sed -e '/-/!s/^/ /' -e 's/^/ /' | sort -nb
-1
0
-0
1
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
next reply other threads:[~2008-12-31 21:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-31 21:39 Buchbinder, Barry (NIH/NIAID) [E] [this message]
2009-01-02 23:07 ` Dave Korn
2009-01-07 14:27 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0105D5C1E0353146B1B222348B0411A211B41DEC@NIHMLBX02.nih.gov \
--to=bbuchbinder@niaid.nih.gov \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).