PHP Function Natsort
php function natsort is used to sort an array by using a natural order algorithm. It preserves the original keys and values of the array while sorting.
This method is useful for comparing string values, as it treats numbers as numerical values rather than individual characters. For example, in human readable format 30 comes before 7, but when sorted by computer it is reversed because the number 30 is less than 7.
The natsort() function takes one argument: the array to be sorted. It returns a boolean value, TRUE on success or FALSE on failure.
A more technical version of natsort is natcasesort, which ignores case. Both functions were introduced in PHP 4.0. For more information see Martin Pool’s Natural Order String Comparison page.
To use this in your gallery shortcode, you would have to implement a filter callback that could distinguish a gallery query from all others (which usually involves reproducing a large part of the get_posts() function into your callback). Another option is to add an extra column to the database and use natsort(int(post_title)) in your SQL statement. This will still leave the DB engine to sort the results by title, but will force it to do so in human readable order.