[prev in list] [next in list] [prev in thread] [next in thread]
List: coreutils-bug
Subject: bug#22084: Potential Bug in sort -r
From: Adria Rovira <adria.rovira () upc ! edu>
Date: 2015-12-03 17:28:43
Message-ID: 56607BCB.4060600 () upc ! edu
[Download RAW message or body]
Dear Assaf,
Thank You very much!!
We didn't read carefully enough the manual.
Best Regards,
AdriÃ
On 12/03/2015 06:18 PM, Assaf Gordon wrote:
> tag 22084 notabug
> close 22084
> stop
>
> Hello Adrià and Deimos,
>
>
> On 12/03/2015 07:30 AM, Adrià Rovira wrote:
>> I noticed the reverse option is not correctly applied if it has to
>> sort by more than one column.
>
> This is not a bug, but simply a usage issue.
> The "sort --help" page states:
> " ... OPTS is one or more single-letter ordering options [bdfgiMhnRrV],
> which override global ordering options for that key. "
>
> That is,
> 1. If you use global sorting option (-n), and a key option WITHOUT
> ordering option (e.g. '-k1,1') - the global sorting option is in
> effect.
>
> 2. If you use *any* sorting option in the key specification
> (e.g. '-k1,1r'), it overrides the global sorting option,
> thus the order in effect is just 'reverse' (implying: alphabetical
> order).
>
> These examples should demonstrate it:
>
> # Input data
> $ printf "1\n07\n2\n"
> 1
> 07
> 2
> # Alphabetical (ascii) sort,
> # character "0" comes before "1"
> $ printf "1\n07\n2\n" | sort
> 07
> 1
> 2
> # Numerical sort, value 7 comes after 2
> $ printf "1\n07\n2\n" | sort -n
> 1
> 2
> 07
> # Global option (-n), key without ordering option:
> # numeric sort in effect
> $ printf "1\n07\n2\n" | sort -n -k1,1
> 1
> 2
> 07
> # Global option (-n), key with any ordering option
> # (in this case 'b' = ignore leading blanks)
> # global numeric ordering is ignore
> $ printf "1\n07\n2\n" | sort -n -k1b,1
> 07
> 1
> 2
> # Adding the numeric ordering to the key -
> # takes effect
> $ printf "1\n07\n2\n" | sort -n -k1bn,1
> 1
> 2
> 07
>
>
> regards,
> - Assaf
>
>
--
--------------------------------------------------------
o o o | Adrià Rovira Garcia
o o o | Research group of Astronomy and GEomatics (gAGE)
o o o | Universitat Politècnica de Catalunya (UPC)
--------------------------------------------------------
gAGE / UPC
Departament de Matemà tiques
C/. Jordi Girona 1-3
Campus Nord UPC
Building C3, Office 211
08034 Barcelona, Spain
Tel:+34 93 401 25 31
Fax:+34 93 401 59 81
http://www.gage.upc.edu
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic