ls sorts filenames strictly lexicographically, comparing character by character, so e.g. "055436307" is compared as the characters "0", "5", "5", etc. so it sorts before "121134" because "0" is less than "1". if all compared characters match and one string ends, the shorter one comes first. Symbols like _ are just more characters, and their position relative to digits depends on the locale’s collation table.
Google Drive uses ICU collation with the numeric option enabled, which treats each consecutive sequence of digits inside the filename as an integer. so "055436307" is parsed as the number 55,436,307, while "121134" is parsed as 121,134. and since 121,134 < 55,436,307 then "121134..." comes before "055436307..." even though lexicographic order would suggest the opposite. and i think when two digit runs have the same numeric value, the shorter run comes first; if runs are equal and the string continues, then normal character comparison resumes, including any underscores or suffixes
The leading zero isn't an issue because it will sort correctly under both systems. The issue OP is having is that he's adding random numbers after the hhmmss section. If instead he added a delimiter before the random number the files would sort correctly under both systems as well, e.g. hhmmss_num.
for me the takeaway here isn't that sorting should use some smarter/better mechanism for inferring semantic intent from filenames, but rather that sorting should not try to infer semantic intent from filenames in the first place
Google Drive uses ICU collation with the numeric option enabled, which treats each consecutive sequence of digits inside the filename as an integer. so "055436307" is parsed as the number 55,436,307, while "121134" is parsed as 121,134. and since 121,134 < 55,436,307 then "121134..." comes before "055436307..." even though lexicographic order would suggest the opposite. and i think when two digit runs have the same numeric value, the shorter run comes first; if runs are equal and the string continues, then normal character comparison resumes, including any underscores or suffixes