Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 316995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:26:05+00:00 2026-05-12T08:26:05+00:00

sort provides two kinds of numeric sort. This is from the man page: -g,

  • 0

sort provides two kinds of numeric sort. This is from the man page:

   -g, --general-numeric-sort
          compare according to general numerical value

   -n, --numeric-sort
          compare according to string numerical value

What’s the difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:26:05+00:00Added an answer on May 12, 2026 at 8:26 am

    General numeric sort compares the numbers as floats, this allows scientific notation eg 1.234E10 but is slower and subject to rounding error (1.2345678 could come after 1.2345679), numeric sort is just a regular alphabetic sort that knows 10 comes after 9.

    See http://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html

    ‘-g’ ‘–general-numeric-sort’
    ‘–sort=general-numeric’ Sort
    numerically, using the standard C
    function strtod to convert a prefix of
    each 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. The LC_NUMERIC locale
    determines the decimal-point
    character. Do not report overflow,
    underflow, or conversion errors. Use
    the following collating sequence:
    Lines that do not start with numbers
    (all considered to be equal). NaNs
    (“Not a Number” values, in IEEE
    floating point arithmetic) in a
    consistent but machine-dependent
    order. Minus infinity. Finite
    numbers in ascending numeric order
    (with -0 and +0 equal). Plus
    infinity.

    Use this option only if there is no
    alternative; it is much slower than
    –numeric-sort (-n) and it can lose information when converting to
    floating point.

    ‘-n’ ‘–numeric-sort’ ‘–sort=numeric’
    Sort numerically. The number begins
    each line and consists of optional
    blanks, an optional ‘-’ 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
    LC_NUMERIC locale specifies the
    decimal-point character and thousands
    separator. By default a blank is a
    space or a tab, but the LC_CTYPE
    locale can change this.

    Comparison is exact; there is no
    rounding error.

    Neither a leading ‘+’ nor exponential
    notation is recognized. To compare
    such strings numerically, use the
    –general-numeric-sort (-g) option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to sort files by modification time ascending and descending. According to this
I sort of understand this, at least the function of generators (I've used them
The following code provides two approaches that generate pairs of integers whose sum is
This is sort of a follow up to a previous question, but I'll repost
Greetings, Trying to sort through the best way to provide access to my Entity
Sort of noob-rails question ;): I've got 2 actions in my controller - index
...@Sort bit) AS SELECT .............. and I want to Order only if Sort =
Sort of a methods/best practices question here that I am sure has been addressed,
A (sort of - it's not directly to do with C#) related question in
what sort of conditions can we use for branching in jinja2? I mean can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.