public enum SortOption extends Enum<SortOption> implements Option, SortOptions
sort
command.
For most applications, it may be more convenient to use Sort.Options
instead of the option constants defined here.
-c | --check | Checks that the single input file is ordered as specified by the arguments and the collating sequence of the current locale. No output is produced; only the exit code is affected. | |||
-m | --merge | Merge only; the input file are assumed to be already sorted. | |||
-u | --unique | Unique: suppress all but one in each set of lines having equal keys.
If used with the -c option, checks that there are no lines
with duplicate keys, in addition to checking that the input file is
sorted. | |||
-b | --ignoreLeadingBlanks | Ignore leading blanks. (This option is ignored if a comparator operand is present). | |||
-d | --dictionaryOrder | Consider only blanks and alphanumeric characters. (This option is ignored if a comparator operand is present). | |||
-f | --ignoreCase | Consider all lowercase characters that have uppercase equivalents to be the uppercase equivalent for the purposes of comparison. (This option is ignored if a comparator operand is present). | |||
-n | --numericSort | Sort numerically; the number begins each line and consists of
optional blanks, an optional minus sign, and zero or more digits
possibly separated by thousands separators, optionally followed by a
decimal-point character and zero or more digits. An empty number is
treated as '0'. The current local specifies the decimal-point
character and thousands separator.
Comparison is exact; there is no rounding error.
Neither a leading '+' nor exponential notation is recognized. To
compare such strings numerically, use the
(This option is ignored if a comparator operand is present). | |||
-g | --generalNumericSort | Sort numerically, using the standard Double.parseDouble(String)
function to convert a trimmed line to a double-precision floating
point number. This allows floating point numbers to be specified in
scientific notation, like 1.0e-34 and 10e100.
Uses the following collating sequence: Lines that cannot be parsed because they do not represent valid double values (in alpha-numeric order); "-Infinity"; finite numbers in ascending numeric order (with -0 < +0); "Infinity"; "NaN".
This option is usually slower than (This option is ignored if a comparator operand is present). | |||
-h | --humanNumericSort | Sort numerically, first by numeric sign (negative, zero, or
positive); then by SI suffix (either empty, or 'k' or 'K', or one
of 'MGTPEZY', in that order); and finally by numeric value. For
example, '1023M' sorts before '1G' because 'M' (mega) precedes 'G'
(giga) as an SI suffix.
This option sorts values that are consistently scaled to the nearest
suffix, regardless of whether suffixes denote powers of 1000 or
1024, and it therefore sorts the output of any single invocation of
the
The syntax for numbers is the same as for the
(This option is ignored if a comparator operand is present). | |||
-M | --monthSort | An initial string, consisting of any amount of blanks, followed by a month name abbreviation, is folded to UPPER case and compared in the order: (unknown) < 'JAN' < ... < 'DEC'. The current locale determines the month spellings. | |||
-V | --versionSort | Sort by version name and number. It behaves like a standard sort,
except that each sequence of decimal digits is treated numerically
as an index/version number.
(This option is ignored if a comparator operand is present). | |||
-r | --reverse | Reverse the sense of comparisons. |
SortOptions.Default
Enum Constant and Description |
---|
check
Option
--check , -c :
Checks that the single input file is ordered as specified by the
arguments and the collating sequence of the current locale. |
dictionaryOrder
Option
--dictionaryOrder , -d :
Consider only blanks and alphanumeric characters. |
generalNumericSort
Option
--generalNumericSort , -g :
Sort numerically, using the standard Double.parseDouble(String)
function to convert a trimmed line to a double-precision floating
point number. |
humanNumericSort
Option
--humanNumericSort , -h :
Sort numerically, first by numeric sign (negative, zero, or
positive); then by SI suffix (either empty, or 'k' or 'K', or one
of 'MGTPEZY', in that order); and finally by numeric value. |
ignoreCase
Option
--ignoreCase , -f :
Consider all lowercase characters that have uppercase equivalents to
be the uppercase equivalent for the purposes of comparison. |
ignoreLeadingBlanks
Option
--ignoreLeadingBlanks , -b :
Ignore leading blanks. |
merge
Option
--merge , -m :
Merge only; the input file are assumed to be already sorted. |
monthSort
Option
--monthSort , -M :
An initial string, consisting of any amount of blanks, followed by a
month name abbreviation, is folded to UPPER case and compared in the
order: (unknown) < 'JAN' < ... |
numericSort
Option
--numericSort , -n :
Sort numerically; the number begins each line and consists of
optional blanks, an optional minus sign, and zero or more digits
possibly separated by thousands separators, optionally followed by a
decimal-point character and zero or more digits. |
reverse
Option
--reverse , -r :
Reverse the sense of comparisons. |
unique
Option
--unique , -u :
Unique: suppress all but one in each set of lines having equal keys. |
versionSort
Option
--versionSort , -V :
Sort by version name and number. |
CONVERTER, EMPTY
Modifier and Type | Method and Description |
---|---|
char |
acronym()
Returns a one letter acronym for this option.
|
EnumSet<SortOption> |
asSet()
Returns a new set with
this active option. |
static SortOption |
findByAcronym(char acronym)
Returns the option with the given
acronym , or null if no
such option is found. |
boolean |
isSet(SortOption option)
Returns true if the specified
option is set and false otherwise |
Iterator<SortOption> |
iterator()
Returns an immutable iterator returning o single element:
this
option. |
Class<SortOption> |
optionType()
Returns the option type class, usually an enum.
|
int |
size()
Returns 1 as this is a set with a single element:
this option |
boolean |
useAcronymFor(SortOption option)
Returns true if the
acronym should be used for
the specified option in string representations. |
static SortOption |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SortOption[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
forEach, spliterator
public static final SortOption check
--check
, -c
:
Checks that the single input file is ordered as specified by the
arguments and the collating sequence of the current locale. No
output is produced; only the exit code is affected.public static final SortOption merge
--merge
, -m
:
Merge only; the input file are assumed to be already sorted.public static final SortOption unique
--unique
, -u
:
Unique: suppress all but one in each set of lines having equal keys.
If used with the -c
option, checks that there are no lines
with duplicate keys, in addition to checking that the input file is
sorted.public static final SortOption ignoreLeadingBlanks
--ignoreLeadingBlanks
, -b
:
Ignore leading blanks.
(This option is ignored if a comparator operand is present).public static final SortOption dictionaryOrder
--dictionaryOrder
, -d
:
Consider only blanks and alphanumeric characters.
(This option is ignored if a comparator operand is present).public static final SortOption ignoreCase
--ignoreCase
, -f
:
Consider all lowercase characters that have uppercase equivalents to
be the uppercase equivalent for the purposes of comparison.
(This option is ignored if a comparator operand is present).public static final SortOption numericSort
--numericSort
, -n
:
Sort numerically; the number begins each line and consists of
optional blanks, an optional minus sign, and zero or more digits
possibly separated by thousands separators, optionally followed by a
decimal-point character and zero or more digits. An empty number is
treated as '0'. The current local specifies the decimal-point
character and thousands separator.
Comparison is exact; there is no rounding error.
Neither a leading '+' nor exponential notation is recognized. To
compare such strings numerically, use the
-genericNumericSort (-g)
option.
(This option is ignored if a comparator operand is present).
public static final SortOption generalNumericSort
--generalNumericSort
, -g
:
Sort numerically, using the standard Double.parseDouble(String)
function to convert a trimmed line to a double-precision floating
point number. This allows floating point numbers to be specified in
scientific notation, like 1.0e-34 and 10e100.
Uses the following collating sequence: Lines that cannot be parsed because they do not represent valid double values (in alpha-numeric order); "-Infinity"; finite numbers in ascending numeric order (with -0 < +0); "Infinity"; "NaN".
This option is usually slower than -numeric-sort (-n)
and it
can lose information when converting to floating point.
(This option is ignored if a comparator operand is present).
public static final SortOption humanNumericSort
--humanNumericSort
, -h
:
Sort numerically, first by numeric sign (negative, zero, or
positive); then by SI suffix (either empty, or 'k' or 'K', or one
of 'MGTPEZY', in that order); and finally by numeric value. For
example, '1023M' sorts before '1G' because 'M' (mega) precedes 'G'
(giga) as an SI suffix.
This option sorts values that are consistently scaled to the nearest
suffix, regardless of whether suffixes denote powers of 1000 or
1024, and it therefore sorts the output of any single invocation of
the ls
command that are invoked with the --human-readable
option.
The syntax for numbers is the same as for the
--numericSort (-n)
option; the SI suffix must immediately
follow the number.
(This option is ignored if a comparator operand is present).
public static final SortOption monthSort
--monthSort
, -M
:
An initial string, consisting of any amount of blanks, followed by a
month name abbreviation, is folded to UPPER case and compared in the
order: (unknown) < 'JAN' < ... < 'DEC'. The current locale
determines the month spellings.public static final SortOption versionSort
--versionSort
, -V
:
Sort by version name and number. It behaves like a standard sort,
except that each sequence of decimal digits is treated numerically
as an index/version number.
(This option is ignored if a comparator operand is present).
public static final SortOption reverse
--reverse
, -r
:
Reverse the sense of comparisons.public static SortOption[] values()
for (SortOption c : SortOption.values()) System.out.println(c);
public static SortOption valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic Class<SortOption> optionType()
OptionSet
optionType
in interface OptionSet<SortOption>
public static SortOption findByAcronym(char acronym)
acronym
, or null
if no
such option is found.acronym
- the option acronym
acronym
or null
if it
is not foundpublic char acronym()
Option
public boolean isSet(SortOption option)
OptionSet
option
is set and false otherwiseisSet
in interface OptionSet<SortOption>
option
- the option to testoption
is set in this OptionSet
public EnumSet<SortOption> asSet()
this
active option.asSet
in interface OptionSet<SortOption>
public Iterator<SortOption> iterator()
this
option.iterator
in interface Iterable<SortOption>
iterator
in interface OptionSet<SortOption>
this
active option.public int size()
this
optionsize
in interface OptionSet<SortOption>
public boolean useAcronymFor(SortOption option)
acronym
should be used for
the specified option
in string representations.
This method returns always true for all options.
useAcronymFor
in interface OptionSet<SortOption>
option
- the option of interestCopyright © 2024. All rights reserved.