001package org.unix4j.unix; 002 003import org.unix4j.command.CommandInterface; 004 005import org.unix4j.unix.sort.SortFactory; 006import org.unix4j.unix.sort.SortOption; 007import org.unix4j.unix.sort.SortOptions; 008import org.unix4j.unix.sort.SortOptionSets; 009 010/** 011 * Non-instantiable module with inner types making up the <b>sort</b> command. 012 * <p> 013 * <b>NAME</b> 014 * <p> 015 * sort - sort, merge, or sequence check text files 016 * <p> 017 * <b>SYNOPSIS</b> 018 * <p> 019 * <table> 020 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort}</td></tr> 021 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort <args>}</td></tr> 022 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort <files>}</td></tr> 023 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort <comparator>}</td></tr> 024 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort <comparator> <files>}</td></tr> 025 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort <comparator> <paths>}</td></tr> 026 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr]}</td></tr> 027 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr] <files>}</td></tr> 028 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr] <paths>}</td></tr> 029 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr] <comparator>}</td></tr> 030 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr] <comparator> <files>}</td></tr> 031 * <tr><td width="10px"></td><td nowrap="nowrap">{@code sort [-cmubdfnghMVr] <comparator> <paths>}</td></tr> 032 * </table> 033 * <p> 034 * See {@link Interface} for the corresponding command signature methods. 035 * <p> 036 * <b>DESCRIPTION</b> 037 * <p> 038 * <p> The sort utility performs one of the following functions: <ol> <li> Sort lines of all the named files together and write the result to the specified output. </li> <li> Merge lines of all the named (presorted) files together and write the result to the specified output. </li> <li> Check that a single input file is correctly presorted. </li> </ol></p><p> Comparisons are based on one or more sort keys/fields extracted from each line of input. If no sort keys/fields are specified, comparisons are based on the entire line up to, but not including, the terminating <newline>. All comparisons are performed using the collating sequence of the current locale.</p><p> Sorting is stable, that is, the ordering of input lines is preserved if they are considered equal according to the current comparison criteria (if two lines originate from different input files, the index of the file in the input arguments list defines the ordering of the lines). </p> 039 * 040 * <p> 041 * <b>NOTES</b> 042 * <p> 043 * <ul> 044 * <li>A <newline> is added to the end of an input line if it is not 045 properly terminated with a line ending (usually the last line in a file)</li> 046 * 047 * <li>The following sort order options are currently not supported: {@code dictionaryOrder}, {@code humanNumericSort}, {@code monthSort}, {@code versionSort}</li> 048 * </ul> 049 * 050 * <p> 051 * <b>Options</b> 052 * <p> 053 * The following options are supported: 054 * <p> 055 * <table> 056 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -c}</td><td> </td><td nowrap="nowrap">{@code --check}</td><td> </td><td>Checks that the single input file is ordered as specified by the 057 arguments and the collating sequence of the current locale. No 058 output is produced; only the exit code is affected.</td></tr> 059 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -m}</td><td> </td><td nowrap="nowrap">{@code --merge}</td><td> </td><td>Merge only; the input file are assumed to be already sorted.</td></tr> 060 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -u}</td><td> </td><td nowrap="nowrap">{@code --unique}</td><td> </td><td>Unique: suppress all but one in each set of lines having equal keys. 061 If used with the {@code -c} option, checks that there are no lines 062 with duplicate keys, in addition to checking that the input file is 063 sorted.</td></tr> 064 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -b}</td><td> </td><td nowrap="nowrap">{@code --ignoreLeadingBlanks}</td><td> </td><td>Ignore leading blanks. 065 (This option is ignored if a comparator operand is present).</td></tr> 066 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -d}</td><td> </td><td nowrap="nowrap">{@code --dictionaryOrder}</td><td> </td><td>Consider only blanks and alphanumeric characters. 067 (This option is ignored if a comparator operand is present).</td></tr> 068 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -f}</td><td> </td><td nowrap="nowrap">{@code --ignoreCase}</td><td> </td><td>Consider all lowercase characters that have uppercase equivalents to 069 be the uppercase equivalent for the purposes of comparison. 070 (This option is ignored if a comparator operand is present).</td></tr> 071 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -n}</td><td> </td><td nowrap="nowrap">{@code --numericSort}</td><td> </td><td>Sort numerically; the number begins each line and consists of 072 optional blanks, an optional minus sign, and zero or more digits 073 possibly separated by thousands separators, optionally followed by a 074 decimal-point character and zero or more digits. An empty number is 075 treated as '0'. The current local specifies the decimal-point 076 character and thousands separator. 077 <p> 078 Comparison is exact; there is no rounding error. 079 <p> 080 Neither a leading '+' nor exponential notation is recognized. To 081 compare such strings numerically, use the 082 {@code -genericNumericSort (-g)} option. 083<p> 084 (This option is ignored if a comparator operand is present).</td></tr> 085 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -g}</td><td> </td><td nowrap="nowrap">{@code --generalNumericSort}</td><td> </td><td>Sort numerically, using the standard {@link Double#parseDouble(String)} 086 function to convert a trimmed line to a double-precision floating 087 point number. This allows floating point numbers to be specified in 088 scientific notation, like 1.0e-34 and 10e100. 089 <p> 090 Uses the following collating sequence: Lines that cannot be parsed 091 because they do not represent valid double values (in alpha-numeric 092 order); "-Infinity"; finite numbers in ascending numeric order 093 (with -0 < +0); "Infinity"; "NaN". 094<p> 095 This option is usually slower than {@code -numeric-sort (-n)} and it 096 can lose information when converting to floating point. 097 <p> 098 (This option is ignored if a comparator operand is present).</td></tr> 099 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -h}</td><td> </td><td nowrap="nowrap">{@code --humanNumericSort}</td><td> </td><td>Sort numerically, first by numeric sign (negative, zero, or 100 positive); then by SI suffix (either empty, or 'k' or 'K', or one 101 of 'MGTPEZY', in that order); and finally by numeric value. For 102 example, '1023M' sorts before '1G' because 'M' (mega) precedes 'G' 103 (giga) as an SI suffix. 104 <p> 105 This option sorts values that are consistently scaled to the nearest 106 suffix, regardless of whether suffixes denote powers of 1000 or 107 1024, and it therefore sorts the output of any single invocation of 108 the {@code ls} command that are invoked with the --human-readable 109 option. 110 <p> 111 The syntax for numbers is the same as for the 112 {@code --numericSort (-n)} option; the SI suffix must immediately 113 follow the number. 114<p> 115 (This option is ignored if a comparator operand is present).</td></tr> 116 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -M}</td><td> </td><td nowrap="nowrap">{@code --monthSort}</td><td> </td><td>An initial string, consisting of any amount of blanks, followed by a 117 month name abbreviation, is folded to UPPER case and compared in the 118 order: (unknown) < 'JAN' < ... < 'DEC'. The current locale 119 determines the month spellings.</td></tr> 120 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -V}</td><td> </td><td nowrap="nowrap">{@code --versionSort}</td><td> </td><td>Sort by version name and number. It behaves like a standard sort, 121 except that each sequence of decimal digits is treated numerically 122 as an index/version number. 123 <p> 124 (This option is ignored if a comparator operand is present).</td></tr> 125 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -r}</td><td> </td><td nowrap="nowrap">{@code --reverse}</td><td> </td><td>Reverse the sense of comparisons.</td></tr> 126 * </table> 127 * <p> 128 * <b>OPERANDS</b> 129 * <p> 130 * The following operands are supported: 131 * <p> 132 * <table> 133 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <paths>}</td><td> : </td><td nowrap="nowrap">{@code String...}</td><td> </td><td>Pathnames of the files to be sorted, merged, or checked; wildcards * 134 and ? are supported; relative paths are resolved on the 135 basis of the current working directory.</td></tr> 136 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <files>}</td><td> : </td><td nowrap="nowrap">{@code java.io.File...}</td><td> </td><td>The files to be sorted or merged; relative paths are not resolved 137 (use the string paths argument to enable relative path resolving 138 based on the current working directory).</td></tr> 139 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <comparator>}</td><td> : </td><td nowrap="nowrap">{@code java.util.Comparator<? super org.unix4j.line.Line>}</td><td> </td><td>The comparator to use for the line comparisons.</td></tr> 140 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <args>}</td><td> : </td><td nowrap="nowrap">{@code String...}</td><td> </td><td>String arguments defining the options and operands for the command. 141 Options can be specified by acronym (with a leading dash "-") or by 142 long name (with two leading dashes "--"). Operands other than the 143 default "--paths" operand have to be prefixed with the operand 144 name (e.g. "--comparator" for a subsequent comparator operand value).</td></tr> 145 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <options>}</td><td> : </td><td nowrap="nowrap">{@code SortOptions}</td><td> </td><td>The options for the sort command.</td></tr> 146 * </table> 147 */ 148public final class Sort { 149 /** 150 * The "sort" command name. 151 */ 152 public static final String NAME = "sort"; 153 154 /** 155 * Interface defining all method signatures for the "sort" command. 156 * 157 * @param <R> 158 * the generic return type for all command signature methods 159 * to support different implementor types; the methods of a 160 * command factory for instance returns a command instance; 161 * command builders can also implement this interface, but their 162 * methods return the builder itself enabling for chained method 163 * invocation to create joined commands 164 */ 165 public static interface Interface<R> extends CommandInterface<R> { 166 /** 167 * Sort the lines read from the standard input and writes the result to 168 the standard output. 169 <p> 170 Comparisons are based on the entire line without line ending. The 171 collating sequence of the current locale is used to perform the 172 comparisons. 173 <p> 174 The sort algorithm used is guaranteed to be stable: lines considered 175 equal will not be reordered as a result of the sort. 176 * 177 * @return the generic type {@code <R>} defined by the implementing class; 178 * the command itself returns no value and writes its result to the 179 * standard output; see class level parameter comments for more 180 * details 181 */ 182 R sort(); 183 /** 184 * Sort the lines of all the specified files together and writes the 185 result to the standard output. 186 <p> 187 Options can be specified by acronym (with a leading dash "-") or by 188 long name (with two leading dashes "--"). Operands other than the 189 default "--paths" operand have to be prefixed with the operand 190 name. 191 <p> 192 The sort algorithm used is guaranteed to be stable: lines considered 193 equal will not be reordered as a result of the sort. If two lines 194 originate from different input files, the index of the file in the 195 input arguments list defines the ordering of the lines. 196 * 197 * @param args String arguments defining the options and operands for the command. 198 Options can be specified by acronym (with a leading dash "-") or by 199 long name (with two leading dashes "--"). Operands other than the 200 default "--paths" operand have to be prefixed with the operand 201 name (e.g. "--comparator" for a subsequent comparator operand value). 202 * @return the generic type {@code <R>} defined by the implementing class; 203 * the command itself returns no value and writes its result to the 204 * standard output; see class level parameter comments for more 205 * details 206 */ 207 R sort(String... args); 208 /** 209 * Sort the lines of all the specified files together and writes the 210 result to the standard output. 211 <p> 212 Comparisons are based on the entire line without line ending. The 213 collating sequence of the current locale is used to perform the 214 comparisons. 215 <p> 216 The sort algorithm used is guaranteed to be stable: lines considered 217 equal will not be reordered as a result of the sort. If two lines 218 originate from different input files, the index of the file in the 219 input arguments list defines the ordering of the lines. 220 * 221 * @param files The files to be sorted or merged; relative paths are not resolved 222 (use the string paths argument to enable relative path resolving 223 based on the current working directory). 224 * @return the generic type {@code <R>} defined by the implementing class; 225 * the command itself returns no value and writes its result to the 226 * standard output; see class level parameter comments for more 227 * details 228 */ 229 R sort(java.io.File... files); 230 /** 231 * Sort the lines read from the standard input and writes the result to 232 the standard output. 233 <p> 234 Line comparisons are based on the specified {@code comparator}. 235 <p> 236 The sort algorithm used is guaranteed to be stable: lines considered 237 equal will not be reordered as a result of the sort. 238 * 239 * @param comparator The comparator to use for the line comparisons. 240 * @return the generic type {@code <R>} defined by the implementing class; 241 * the command itself returns no value and writes its result to the 242 * standard output; see class level parameter comments for more 243 * details 244 */ 245 R sort(java.util.Comparator<? super org.unix4j.line.Line> comparator); 246 /** 247 * Sort the lines of all the specified files together and writes the 248 result to the standard output. 249 <p> 250 Line comparisons are based on the specified {@code comparator}. 251 <p> 252 The sort algorithm used is guaranteed to be stable: lines considered 253 equal will not be reordered as a result of the sort. If two lines 254 originate from different input files, the index of the file in the 255 input arguments list defines the ordering of the lines. 256 * 257 * @param comparator The comparator to use for the line comparisons. 258 * @param files The files to be sorted or merged; relative paths are not resolved 259 (use the string paths argument to enable relative path resolving 260 based on the current working directory). 261 * @return the generic type {@code <R>} defined by the implementing class; 262 * the command itself returns no value and writes its result to the 263 * standard output; see class level parameter comments for more 264 * details 265 */ 266 R sort(java.util.Comparator<? super org.unix4j.line.Line> comparator, java.io.File... files); 267 /** 268 * Sort the lines of all the specified files together and writes the 269 result to the standard output. 270 <p> 271 Line comparisons are based on the specified {@code comparator}. 272 <p> 273 The sort algorithm used is guaranteed to be stable: lines considered 274 equal will not be reordered as a result of the sort. If two lines 275 originate from different input files, the index of the file in the 276 input arguments list defines the ordering of the lines. 277 * 278 * @param comparator The comparator to use for the line comparisons. 279 * @param paths Pathnames of the files to be sorted, merged, or checked; wildcards * 280 and ? are supported; relative paths are resolved on the 281 basis of the current working directory. 282 * @return the generic type {@code <R>} defined by the implementing class; 283 * the command itself returns no value and writes its result to the 284 * standard output; see class level parameter comments for more 285 * details 286 */ 287 R sort(java.util.Comparator<? super org.unix4j.line.Line> comparator, String... paths); 288 /** 289 * Sorts, merges, or sequence checks the lines read from the standard 290 input and writes the result to the standard output. 291 <p> 292 Comparisons are based on the entire line without line ending. The 293 collating sequence of the current locale is used to perform the 294 comparisons. 295 <p> 296 The sort algorithm used is guaranteed to be stable: lines considered 297 equal will not be reordered as a result of the sort. 298 * 299 * @param options The options for the sort command. 300 * @return the generic type {@code <R>} defined by the implementing class; 301 * the command itself returns no value and writes its result to the 302 * standard output; see class level parameter comments for more 303 * details 304 */ 305 R sort(SortOptions options); 306 /** 307 * Sorts, merges, or sequence checks the lines the lines of all the 308 specified files together and writes the result to the standard 309 output. 310 <p> 311 Comparisons are based on the entire line without line ending. The 312 collating sequence of the current locale is used to perform the 313 comparisons. 314 <p> 315 The sort algorithm used is guaranteed to be stable: lines considered 316 equal will not be reordered as a result of the sort. If two lines 317 originate from different input files, the index of the file in the 318 input arguments list defines the ordering of the lines. 319 * 320 * @param options The options for the sort command. 321 * @param files The files to be sorted or merged; relative paths are not resolved 322 (use the string paths argument to enable relative path resolving 323 based on the current working directory). 324 * @return the generic type {@code <R>} defined by the implementing class; 325 * the command itself returns no value and writes its result to the 326 * standard output; see class level parameter comments for more 327 * details 328 */ 329 R sort(SortOptions options, java.io.File... files); 330 /** 331 * Sorts, merges, or sequence checks the lines the lines of all the 332 specified files together and writes the result to the standard 333 output. 334 <p> 335 Comparisons are based on the entire line without line ending. The 336 collating sequence of the current locale is used to perform the 337 comparisons. 338 <p> 339 The sort algorithm used is guaranteed to be stable: lines considered 340 equal will not be reordered as a result of the sort. If two lines 341 originate from different input files, the index of the file in the 342 input arguments list defines the ordering of the lines. 343 * 344 * @param options The options for the sort command. 345 * @param paths Pathnames of the files to be sorted, merged, or checked; wildcards * 346 and ? are supported; relative paths are resolved on the 347 basis of the current working directory. 348 * @return the generic type {@code <R>} defined by the implementing class; 349 * the command itself returns no value and writes its result to the 350 * standard output; see class level parameter comments for more 351 * details 352 */ 353 R sort(SortOptions options, String... paths); 354 /** 355 * Sorts, merges, or sequence checks the lines read from the standard 356 input and writes the result to the standard output. 357 <p> 358 Line comparisons are based on the specified {@code comparator}. 359 All comparison related options are ignored except for 360 {@code --reverse}. 361 <p> 362 The sort algorithm used is guaranteed to be stable: lines considered 363 equal will not be reordered as a result of the sort. 364 * 365 * @param options The options for the sort command. 366 * @param comparator The comparator to use for the line comparisons. 367 * @return the generic type {@code <R>} defined by the implementing class; 368 * the command itself returns no value and writes its result to the 369 * standard output; see class level parameter comments for more 370 * details 371 */ 372 R sort(SortOptions options, java.util.Comparator<? super org.unix4j.line.Line> comparator); 373 /** 374 * Sorts, merges, or sequence checks the lines the lines of all the 375 specified files together and writes the result to the standard 376 output. 377 <p> 378 Line comparisons are based on the specified {@code comparator}. 379 All comparison related options except for {@code --reverse} are 380 ignored. 381 <p> 382 The sort algorithm used is guaranteed to be stable: lines considered 383 equal will not be reordered as a result of the sort. If two lines 384 originate from different input files, the index of the file in the 385 input arguments list defines the ordering of the lines. 386 * 387 * @param options The options for the sort command. 388 * @param comparator The comparator to use for the line comparisons. 389 * @param files The files to be sorted or merged; relative paths are not resolved 390 (use the string paths argument to enable relative path resolving 391 based on the current working directory). 392 * @return the generic type {@code <R>} defined by the implementing class; 393 * the command itself returns no value and writes its result to the 394 * standard output; see class level parameter comments for more 395 * details 396 */ 397 R sort(SortOptions options, java.util.Comparator<? super org.unix4j.line.Line> comparator, java.io.File... files); 398 /** 399 * Sorts, merges, or sequence checks the lines the lines of all the 400 specified files together and writes the result to the standard 401 output. 402 <p> 403 Line comparisons are based on the specified {@code comparator}. 404 All comparison related options except for {@code --reverse} are 405 ignored. 406 <p> 407 The sort algorithm used is guaranteed to be stable: lines considered 408 equal will not be reordered as a result of the sort. If two lines 409 originate from different input files, the index of the file in the 410 input arguments list defines the ordering of the lines. 411 * 412 * @param options The options for the sort command. 413 * @param comparator The comparator to use for the line comparisons. 414 * @param paths Pathnames of the files to be sorted, merged, or checked; wildcards * 415 and ? are supported; relative paths are resolved on the 416 basis of the current working directory. 417 * @return the generic type {@code <R>} defined by the implementing class; 418 * the command itself returns no value and writes its result to the 419 * standard output; see class level parameter comments for more 420 * details 421 */ 422 R sort(SortOptions options, java.util.Comparator<? super org.unix4j.line.Line> comparator, String... paths); 423 } 424 425 /** 426 * Options for the "sort" command: {@link SortOption#check c}, {@link SortOption#merge m}, {@link SortOption#unique u}, {@link SortOption#ignoreLeadingBlanks b}, {@link SortOption#dictionaryOrder d}, {@link SortOption#ignoreCase f}, {@link SortOption#numericSort n}, {@link SortOption#generalNumericSort g}, {@link SortOption#humanNumericSort h}, {@link SortOption#monthSort M}, {@link SortOption#versionSort V}, {@link SortOption#reverse r}. 427 * <p> 428 * <table> 429 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -c}</td><td> </td><td nowrap="nowrap">{@code --check}</td><td> </td><td>Checks that the single input file is ordered as specified by the 430 arguments and the collating sequence of the current locale. No 431 output is produced; only the exit code is affected.</td></tr> 432 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -m}</td><td> </td><td nowrap="nowrap">{@code --merge}</td><td> </td><td>Merge only; the input file are assumed to be already sorted.</td></tr> 433 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -u}</td><td> </td><td nowrap="nowrap">{@code --unique}</td><td> </td><td>Unique: suppress all but one in each set of lines having equal keys. 434 If used with the {@code -c} option, checks that there are no lines 435 with duplicate keys, in addition to checking that the input file is 436 sorted.</td></tr> 437 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -b}</td><td> </td><td nowrap="nowrap">{@code --ignoreLeadingBlanks}</td><td> </td><td>Ignore leading blanks. 438 (This option is ignored if a comparator operand is present).</td></tr> 439 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -d}</td><td> </td><td nowrap="nowrap">{@code --dictionaryOrder}</td><td> </td><td>Consider only blanks and alphanumeric characters. 440 (This option is ignored if a comparator operand is present).</td></tr> 441 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -f}</td><td> </td><td nowrap="nowrap">{@code --ignoreCase}</td><td> </td><td>Consider all lowercase characters that have uppercase equivalents to 442 be the uppercase equivalent for the purposes of comparison. 443 (This option is ignored if a comparator operand is present).</td></tr> 444 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -n}</td><td> </td><td nowrap="nowrap">{@code --numericSort}</td><td> </td><td>Sort numerically; the number begins each line and consists of 445 optional blanks, an optional minus sign, and zero or more digits 446 possibly separated by thousands separators, optionally followed by a 447 decimal-point character and zero or more digits. An empty number is 448 treated as '0'. The current local specifies the decimal-point 449 character and thousands separator. 450 <p> 451 Comparison is exact; there is no rounding error. 452 <p> 453 Neither a leading '+' nor exponential notation is recognized. To 454 compare such strings numerically, use the 455 {@code -genericNumericSort (-g)} option. 456<p> 457 (This option is ignored if a comparator operand is present).</td></tr> 458 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -g}</td><td> </td><td nowrap="nowrap">{@code --generalNumericSort}</td><td> </td><td>Sort numerically, using the standard {@link Double#parseDouble(String)} 459 function to convert a trimmed line to a double-precision floating 460 point number. This allows floating point numbers to be specified in 461 scientific notation, like 1.0e-34 and 10e100. 462 <p> 463 Uses the following collating sequence: Lines that cannot be parsed 464 because they do not represent valid double values (in alpha-numeric 465 order); "-Infinity"; finite numbers in ascending numeric order 466 (with -0 < +0); "Infinity"; "NaN". 467<p> 468 This option is usually slower than {@code -numeric-sort (-n)} and it 469 can lose information when converting to floating point. 470 <p> 471 (This option is ignored if a comparator operand is present).</td></tr> 472 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -h}</td><td> </td><td nowrap="nowrap">{@code --humanNumericSort}</td><td> </td><td>Sort numerically, first by numeric sign (negative, zero, or 473 positive); then by SI suffix (either empty, or 'k' or 'K', or one 474 of 'MGTPEZY', in that order); and finally by numeric value. For 475 example, '1023M' sorts before '1G' because 'M' (mega) precedes 'G' 476 (giga) as an SI suffix. 477 <p> 478 This option sorts values that are consistently scaled to the nearest 479 suffix, regardless of whether suffixes denote powers of 1000 or 480 1024, and it therefore sorts the output of any single invocation of 481 the {@code ls} command that are invoked with the --human-readable 482 option. 483 <p> 484 The syntax for numbers is the same as for the 485 {@code --numericSort (-n)} option; the SI suffix must immediately 486 follow the number. 487<p> 488 (This option is ignored if a comparator operand is present).</td></tr> 489 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -M}</td><td> </td><td nowrap="nowrap">{@code --monthSort}</td><td> </td><td>An initial string, consisting of any amount of blanks, followed by a 490 month name abbreviation, is folded to UPPER case and compared in the 491 order: (unknown) < 'JAN' < ... < 'DEC'. The current locale 492 determines the month spellings.</td></tr> 493 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -V}</td><td> </td><td nowrap="nowrap">{@code --versionSort}</td><td> </td><td>Sort by version name and number. It behaves like a standard sort, 494 except that each sequence of decimal digits is treated numerically 495 as an index/version number. 496 <p> 497 (This option is ignored if a comparator operand is present).</td></tr> 498 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -r}</td><td> </td><td nowrap="nowrap">{@code --reverse}</td><td> </td><td>Reverse the sense of comparisons.</td></tr> 499 * </table> 500 */ 501 public static final SortOptionSets Options = SortOptionSets.INSTANCE; 502 503 /** 504 * Singleton {@link SortFactory factory} instance for the "sort" command. 505 */ 506 public static final SortFactory Factory = SortFactory.INSTANCE; 507 508 // no instances 509 private Sort() { 510 super(); 511 } 512}