# Alphordering Numbers

## Numbers don’t comply with alphabetical order

poorly_ordered is a vector of file names of images of patient samples from different days.

poorly_ordered
#>  [1] "patient101-day9.png"  "patient98-day10.png"  "patient98-day9.png"
#>  [4] "patient99-day9.png"   "patient98-day11.png"  "patient102-day11.png"
#>  [7] "patient102-day10.png" "patient100-day11.png" "patient100-day9.png"
#> [10] "patient101-day11.png" "patient102-day9.png"  "patient99-day10.png"
#> [13] "patient103-day10.png" "patient103-day9.png"  "patient101-day10.png"
#> [16] "patient100-day10.png" "patient103-day11.png" "patient99-day11.png"

How do we get this vector into order? Well, alphabetical order doesn’t work:

sort(poorly_ordered)
#>  [1] "patient100-day10.png" "patient100-day11.png" "patient100-day9.png"
#>  [4] "patient101-day10.png" "patient101-day11.png" "patient101-day9.png"
#>  [7] "patient102-day10.png" "patient102-day11.png" "patient102-day9.png"
#> [10] "patient103-day10.png" "patient103-day11.png" "patient103-day9.png"
#> [13] "patient98-day10.png"  "patient98-day11.png"  "patient98-day9.png"
#> [16] "patient99-day10.png"  "patient99-day11.png"  "patient99-day9.png"

Patient 100 comes before patient 99. This is because 1 comes before 9 in alphabetical order.