import Foundation
let strings = ["a10", "a1", "a23", "a2"]
let sorted = strings.sorted {
$0.compare($1, options: .numeric) == .orderedAscending
}
print(sorted)
// ["a1", "a2", "a10", "a23"]
That said, most languages treat strings this way (or very similar). So I'd suggest that you pad the number instead to match the expected text length so as to avoid some headache later on:
// Make sure the numbers match length
test_13
test_01
test_12
test_03