How do I sort my product price list from most expensive to cheapest?

Start every line with the price, turn on numeric sorting and choose descending: the most expensive item goes to the top and the cheapest to the bottom. You need both. Without numeric sorting the digits are compared one character at a time, and if the price sits at the end of the line the list is ordered by product name instead.

Published · 3 min read

Why the price has to come first

The sorter compares each line from its first character. Write «Coffee 55» and «Honey 120» and the comparison starts at C and H; the order is settled long before the number is reached. I tried four lines with the name first (قهوة 55, عسل 120, ماء 9, تمر 35) using numeric sorting and descending order, and got ماء 9, قهوة 55, عسل 120, تمر 35. That is the names in reverse alphabetical order, with the prices scattered.

So flip the line around: price, then name. If your list lives in a spreadsheet, place the price column before the name column when you copy it out, or rewrite the lines once in that shape.

Why numeric sorting matters

With the option off, digits are treated like letters. The first digit is compared first, so 9 counts as bigger than 1 and ends up above 120 in descending order. These are real results for the list 55 Coffee, 120 Honey, 9 Water, 35 Dates:

  • Descending, numeric off: 9 Water, 55 Coffee, 35 Dates, 120 Honey.
  • Descending, numeric on: 120 Honey, 55 Coffee, 35 Dates, 9 Water.

One trap to watch for: with only three lines (55, 120 and 9), plain ascending order happens to give 120, 55, 9, which looks correct by accident. Add one line such as 35 and the illusion breaks. Keep numeric sorting on for prices every time rather than trusting a result that looked fine once.

The steps in the tool

  1. Open the Line sorter and paste the list, one product per line with the price first.
  2. Tick «Numeric sorting» in the sorting options.
  3. Choose «Descending (Z → A)» to start with the most expensive, or «Ascending» to start with the cheapest.
  4. Copy the result or download it as a text file.

Prices in Arabic digits or with separators

Mixed digit styles are fine. With numeric sorting on, ٥٥ and ٩ are read as 55 and 9 for the comparison only, so the list ٥٥ قهوة, 120 عسل, ٩ ماء, 35 تمر came out in descending order as 120 عسل, ٥٥ قهوة, 35 تمر, ٩ ماء. Each line is still printed exactly as you entered it; to make the digits themselves match, run the result through the Arabic/Persian/Western digit converter.

Decimals and thousands separators are another matter. A price written as 2,100 is read as two separate numbers, 2 and then 100, and in my test it landed below 980 in descending order. Write prices without thousands separators (2100), and if you have halalas or fils, give every line the same number of digits after the point, such as 55.50 and 55.25.

Common questions

Are my lines changed by sorting?

No. The options only affect how lines are compared; every line comes out exactly as you typed it, digits and spaces included.

Two products share a price; which comes first?

When two lines compare as equal, the sort is stable and they keep the order they had in your list, also when descending. If the names after the price differ, the name decides.