The Semitic alphabet that Arabic inherited had twenty-two letters. Arabic has twenty-eight, because the language kept six consonants that the twenty-two letter sequence did not distinguish: tha, kha, dhal, dad, za and ghayn. These six are known in the grammatical tradition as the rawadif, the followers, and the name is literal. They were not slotted into the sequence beside the letters they resemble; they were added to the end of it.
That decision is still visible in the two orders Arabic uses. The abjad order preserves the inherited sequence, running alif, ba, jim, dal and onward through the twenty-two, and then appends the six added letters after it. It is remembered through a set of eight nonsense words, beginning abjad hawwaz hutti, that give the letters in order and that the abjad takes its name from. The modern hija'i order, by contrast, groups the letters by written shape, so that ba, ta and tha stand together because they share one skeleton, and jim, ha and kha stand together for the same reason. That is the order in which the alphabet is now taught and in which dictionaries and indexes are arranged.
The abjad order survives because it carries the numerals. Each letter has a numerical value fixed by its place in the inherited sequence, from alif at one to ghayn at one thousand, and the six appended letters take the six highest values precisely because they came last. This is the reckoning called hisab al-jummal, used for dates in inscriptions and colophons, for chronograms in poetry, and in the letter speculation of some Sufi and occult writers. Two regional conventions exist, the eastern and the western, and they assign several of the values differently.