{
  "id": "least-to-greatest",
  "version": "373c4693e935",
  "status": "published",
  "name": "Least to Greatest Calculator",
  "question": "How do I order least to greatest?",
  "summary": "Puts whole numbers, decimals, negative numbers, fractions and mixed numbers in order from least to greatest, or greatest to least, by their exact values.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/least-to-greatest-calculator",
  "markdown": "https://www.acalculator.org/math/least-to-greatest-calculator.md",
  "kind": "function",
  "method": "Each number is read as an exact fraction (a decimal over a power of ten, a mixed number w a/b as (w × b + a)/b) and the list is sorted by value; equal values keep the order typed.",
  "assumptions": [
    "Commas, semicolons and new lines separate numbers; spaces separate them too, except inside a mixed number such as 1 1/2.",
    "A comma between digits with exactly three digits after it (1,234) could be a thousands separator or a separator between numbers, so the page asks you to type 1234 or 1, 234 instead of guessing.",
    "Numbers are compared exactly, so 0.1 + 0.2 style rounding never changes the order."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "n": {
        "title": "Numbers",
        "description": "The numbers to order, separated by commas, semicolons or new lines: 3/4, -2, 0.7, 1 1/2.",
        "type": "string",
        "maxLength": 20000
      },
      "o": {
        "title": "Order",
        "description": "Least to greatest (ascending) or greatest to least (descending).",
        "type": "string",
        "enum": [
          "up",
          "down"
        ]
      }
    }
  },
  "outputs": {
    "sorted": {
      "label": "In order",
      "description": "The numbers as typed, in the chosen order, separated by commas.",
      "format": "text"
    },
    "chain": {
      "label": "With signs",
      "description": "The ordered numbers joined by <, > or = signs.",
      "format": "text"
    },
    "least": {
      "label": "Least",
      "description": "The smallest number.",
      "format": "text"
    },
    "greatest": {
      "label": "Greatest",
      "description": "The largest number.",
      "format": "text"
    },
    "count": {
      "label": "Count",
      "description": "How many numbers were typed.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "n": "3/4, -2, 0.7, 1 1/2, 2/3, 0",
      "o": "up"
    },
    "outputs": {
      "sorted": "−2, 0, 2/3, 0.7, 3/4, 1 1/2",
      "chain": "−2 < 0 < 2/3 < 0.7 < 3/4 < 1 1/2",
      "least": "−2",
      "greatest": "1 1/2",
      "count": 6
    },
    "text": "From −2 to 1 1/2: −2, 0, 2/3, 0.7, 3/4, 1 1/2."
  },
  "examples": [
    {
      "given": {
        "n": "3/4, -2, 0.7, 1 1/2, 2/3, 0",
        "o": "up"
      },
      "expect": {
        "sorted": "−2, 0, 2/3, 0.7, 3/4, 1 1/2",
        "chain": "−2 < 0 < 2/3 < 0.7 < 3/4 < 1 1/2",
        "least": "−2",
        "greatest": "1 1/2",
        "count": 6
      },
      "source": "OpenStax, Prealgebra 2e, §5.1 Decimals (order decimals: compare them place by place, or on the number line), https://openstax.org/books/prealgebra-2e/pages/5-1-decimals (retrieved 2026-10-05); OpenStax, Prealgebra 2e, §3.1 Introduction to Integers (order positive and negative numbers on the number line), https://openstax.org/books/prealgebra-2e/pages/3-1-introduction-to-integers (retrieved 2026-10-05); hand calculation in content.mdx: 2/3 = 0.666…, 3/4 = 0.75, 1 1/2 = 1.5"
    },
    {
      "given": {
        "n": "0.5, 0.45, 0.405, 0.54",
        "o": "up"
      },
      "expect": {
        "sorted": "0.405, 0.45, 0.5, 0.54"
      },
      "source": "OpenStax, Prealgebra 2e, §5.1 Decimals (order decimals: compare them place by place, or on the number line), https://openstax.org/books/prealgebra-2e/pages/5-1-decimals (retrieved 2026-10-05); hand calculation in content.mdx: compare tenths, then hundredths"
    },
    {
      "given": {
        "n": "1/2; 0.5; 2/4; 1234; -3.25",
        "o": "down"
      },
      "expect": {
        "sorted": "1234, 1/2, 0.5, 2/4, −3.25",
        "chain": "1234 > 1/2 = 0.5 = 2/4 > −3.25",
        "count": 5
      },
      "source": "OpenStax, Prealgebra 2e, §5.1 Decimals (order decimals: compare them place by place, or on the number line), https://openstax.org/books/prealgebra-2e/pages/5-1-decimals (retrieved 2026-10-05); OpenStax, Prealgebra 2e, §3.1 Introduction to Integers (order positive and negative numbers on the number line), https://openstax.org/books/prealgebra-2e/pages/3-1-introduction-to-integers (retrieved 2026-10-05); hand calculation in content.mdx"
    },
    {
      "given": {
        "n": "-7 -3 -10 4",
        "o": "up"
      },
      "expect": {
        "sorted": "−10, −7, −3, 4",
        "least": "−10",
        "greatest": "4"
      },
      "source": "OpenStax, Prealgebra 2e, §3.1 Introduction to Integers (order positive and negative numbers on the number line), https://openstax.org/books/prealgebra-2e/pages/3-1-introduction-to-integers (retrieved 2026-10-05); hand calculation in content.mdx: on the number line, −10 is furthest left"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, §5.1 Decimals: order decimals by comparing place values, or on a number line. CC BY 4.0. Retrieved 2026-10-05. https://openstax.org/books/prealgebra-2e/pages/5-1-decimals",
    "OpenStax, Prealgebra 2e, §3.1 Introduction to Integers: order positive and negative numbers on the number line (a number to the left is less). CC BY 4.0. Retrieved 2026-10-05. https://openstax.org/books/prealgebra-2e/pages/3-1-introduction-to-integers"
  ],
  "related": [
    "greater-than-less-than",
    "fraction-to-decimal",
    "range",
    "integer"
  ],
  "changelog": []
}
