There are two ways in which the hiragana and katakana are commonly ordered. One is the gojūon ordering, and the other is the iroha ordering. Gojū (五十) means 'fifty', and on (音) means 'sound', so gojūon (五十音) means 'fifty sound' ordering. The gojūon ordering is the one that most learners of Japanese will encounter first. For details of the iroha ordering, see How does the i-ro-ha ordering go?
The gojūon is not a modern invention. The earliest example of a gojūon-style layout dates from the period 1004-1028. The earliest example of the iroha ordering is from 1079.
The gojūon order of the consonants in kana originates from the consonant order of Sanskrit.
R.A. Miller, in The Japanese Language, page 128, states
The Indic order of listing phonemes as found in the arrangement of this so-called siddhāṃ script, as well as in all the Indic writing systems, arranges the consonants in the following order: k, kh, g, gh, n̄, c, ch, j, jh, ñ, ṭ, ṭh, ḍ, ḍh, ṇ, t, th, d, dh, n, p, ph, b, bh, m, y, r, l, v, ś, ṣ, s, and h. ... Here the juxtaposition of modern h, Old Japanese F, with Indic p is interesting and significant; the only other point which needs particular comment is the location of modern Japanese s following k. This is easily understood since modern Japanese 's' goes back to the Old Japanese affricate phoneme /ts/ which had an allophone [ts] before Old Japanese /a, ụ, o, ö/ and an allophone [s] before /i, e/.
This answer used information from a post by Kouji Ueshiba.
Copyright © 1994-2021 Ben Bullock