I'm trying to sort these state names by alphabetical order while retaining the number to the left of the state name. I currently cannot figure out how to do this.
I've tried using various forms of gsub
in an attempt to remove the numbers before sorting without any success.
This is the dataset with the states:
print(StateRankings)
# [1] "1. Arizona" "10. Missouri" "11. Tennessee" "12. Florida"
# [5] "13. West Virginia" "14. Kentucky" "15. New Hampshire" "16. Mississippi"
# [9] "17. Wyoming" "18. Alabama" "19. Idaho" "2. Alaska"
#[13] "20. Vermont" "21. Indiana" "22. Arkansas" "23. Wisconsin"
#[17] "24. South Carolina" "25. Nevada" "26. North Carolina" "27. Michigan"
#[21] "28. Louisiana" "29. Ohio" "3. Kansas" "30. Maine"
#[25] "31. Virginia" "32. South Dakota" "33. Pennsylvania" "34. Oregon"
#[29] "35. Nebraska" "36. Iowa" "37. New Mexico" "38. Washington"
#[33] "39. Colorado" "4. Oklahoma" "40. Illinois" "41. Minnesota"
#[37] "42. Delaware" "43. Rhode Island" "44. Maryland" "45. Connecticut"
#[41] "46. California" "47. Hawaii" "48. New Jersey" "49. Massachusetts"
#[45] "5. Montana" "50. New York" "6. Utah" "7. North Dakota"
#[49] "8. Texas" "9. Georgia"