sort support for numeric sort with suffixes

Bug #313152 reported by vlovich
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Fix Released

Bug Description

Binary package hint: coreutils

It would be nice if sort supported an option so that it would be possible to sort the output of the du & df commands when the -h flag is supplied, without having to resort to complicated piping.

Ideally, du -hs * | sort -h would provide the expected intuitive result.

My patch however uses -H as the option instead cause I'm not sure what the policy on using -h is since it tends to be a synonym for help. I believe the only reason that du & df have it is for legacy reasons. However, it's a trivial change if -h is acceptable and would make it more consistent with du & df.

The wording of the documentation in the help printout could also use a little bit of work.

Also, the helper functions I added in strnumcmp could probably me moved into sort.c so that they don't affect the size of all the other utlilities using it, unless they're useful elsewhere (or can be removed because it's already implemented in one of the other files).

Revision history for this message
vlovich (vlovich) wrote :
Revision history for this message
vlovich (vlovich) wrote :

Performance improvement. Since -h appears acceptable on the upstream mailing lists, use that instead.

Revision history for this message
vlovich (vlovich) wrote :

Handle generic case - no guarantee that size suffix is in upper case.

Revision history for this message
vlovich (vlovich) wrote :
Revision history for this message
Andrew McCarthy (andrewmccarthy) wrote :

At least since Maverick (possibly earlier), sort has a "-h" option seems to do what is asked for here. Can this bug be closed as fix-released?

Changed in coreutils (Ubuntu):
status: New → Incomplete
Revision history for this message
C de-Avillez (hggdh2) wrote :

Indeed, so marking Fix Released. @Andrew: thank you for the heads up.

@vlovich: I am sorry this bug fell thru a crack -- I should have seen it a long time ago.

For the record and for the future, whenever you:

* have a patch for coreutils, implementing new options/features or improving it, the best place to discuss it is at the main coreutils mailing list, see

* want to report a bug, or patches for bugs, the correct mailing list is

Again, I am sorry we did not respond to you in a timely way.

Changed in coreutils (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers