Good day, friendly community. I have one trivial question, I decided, just in case, to clarify with you, to do, as they say, once and well.
There is a site on the site there is a menu. The menu is a huge number of links to different sections and just a page. At the moment, this is house and horror, since everything is displayed together and without sorting.
I want to comb it all ie sorted alphabetically by the principle of the Letter-> according to it, the items that begin with the letter. In principle, for myself, I figured out options for how this can be implemented, but I decided to consult just in case. I am not interested in the final code, but the algorithm itself or the principle to whom it is more convenient.

Thank you in advance.

  • one
    array_sort? select * from db order byc string asc? - thunder

2 answers 2

1) The final algorithm has already issued thunder.

If the principle: for the linear menu - everything is ready.

For nested, use the recursive function:

if(is_array($item)){ r_sort($item); } 

Ideally, yes, sort everything at the output stage from the database

  • Understood, in principle, and assumed. Thank you all for the answer. - shanhaichik

If your links are derived from the database, you can, for example, like this:

 "SELECT вашассылка FROM ссылки ORDER BY названиессылок"