I sorted my shipping cities alphabetically and every city starting with Al- ended up grouped at the top; why?

Because sorting compares the name exactly as written, and the article «ال» is part of it. «الرياض» (Riyadh) starts with alef and lam, so it files under alef with «الخبر» and «الدمام», ahead of «تبوك» and «جدة». The sorter does not skip the article; to file each city under its main letter, drop the «ال» before sorting.

Published · 3 min read

What happens with a real city list

Here are six shipping cities as a typical Saudi store writes them: جدة, الرياض, مكة, الدمام, تبوك, الخبر. With Arabic rules in ascending order the sorter returned الخبر, الدمام, الرياض, تبوك, جدة, مكة. The three cities with the article rose to the top together, then sorted among themselves by the letter after «ال»: kha, then dal, then ra.

A longer list shows the same shape: أبها, الخبر, الرياض, العلا, المدينة المنورة, جدة, مكة المكرمة. Abha came first because an alef with hamza sorts before a plain alef, then the block of Al- cities, then everything else.

Is this a bug?

No. It is what the Arabic ordering rules built into your browser say: a word is sorted from its first letter. Many modern indexes and dictionaries skip the article when filing, but that is an editorial choice for whoever owns the list, and the sorter does not make it for you.

The real question is where the list will be used. In a drop-down for choosing a delivery city, customers often look for Riyadh under «ال» because that is how they write it, so the cluster can be convenient. In a printed index or a shipping rate table read letter by letter, you may prefer Riyadh under ra.

How to file them under their main letter

  1. Write the list without the leading «ال»: خبر, دمام, رياض, جدة, مكة, تبوك.
  2. Paste it into the Line sorter with Arabic rules and ascending order.
  3. After sorting, put the article back on the names that need it, by hand or with find and replace in your editor.

The list written without the article came out as تبوك, جدة, خبر, دمام, رياض, مكة. That is a little manual, but it is the honest route: the sorter has no option to ignore the article, and you will not find a button that does it. With a short city list it takes about a minute.

And city names in English?

The same thing happens in English: Al Khobar and Al Madinah file under A. Sorting Jeddah, Al Khobar, Makkah, Dammam, Tabuk, Al Madinah with English rules gave Al Khobar, Al Madinah, Dammam, Jeddah, Makkah, Tabuk. Notice that Dammam is written without Al here, so it went under D. Consistent spelling matters more than the sorting itself.

  • Pick one spelling for each city and use it across the whole list, with the article or without.
  • A list mixing Arabic and English is ordered by the rules you choose: with Arabic rules, the Arabic lines come first.

Common questions

Do «الرياض» and «ٱلرياض» with an alef wasla sort differently?

In my test «ٱلرياض» landed right after «الرياض», because the ordering rules place a marked letter next to its base letter. They are still two different lines, so keep one spelling across the list.

Does this apply to family names like «القحطاني»?

Yes, same principle: any name starting with «ال» files under alef unless you drop the article before sorting.