| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <2ca21dcc0901021506g1ab459b3ya8df823ac9e4a7f2@mail.gmail.com> |
| Date: | Fri, 2 Jan 2009 23:06:15 +0000 |
| From: | "Dave Korn" <dave DOT korn DOT cygwin AT googlemail DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: Inconsistency with sort -n? |
| In-Reply-To: | <0105D5C1E0353146B1B222348B0411A211B41DEC@NIHMLBX02.nih.gov> |
| MIME-Version: | 1.0 |
| References: | <0105D5C1E0353146B1B222348B0411A211B41DEC AT NIHMLBX02 DOT nih DOT gov> |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Buchbinder, Barry (NIH/NIAID) [E] wrote:
> `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?
Kinda depends where it's coming from. Could be newlib, could be cygwin,
could be sort itself. Either the + and - zeros aren't being correctly
converted to their float representations, or the comparison of + vs. - zero
isn't working right, at a first guess.
> 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.
Hacky work-around: " | sort -r | sort [-n|-g] -s". First alphabetic sort
using -r gets all the negative numbers at the start of the list, then adding
stable flag to the numeric sort preserves their relative ordering when they
compare equal.
> Happy Gregorian New Year!
Happy Pastafarian Noodly YARRRR!
cheers,
DaveK
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |