Minimum reproducible example: In a Posit.cloud project:
Cars93b <- cbind(Cars93,Cars93,Cars93,Cars93)
The first few columns sort correctly when you click the variable name. However, if you go to the last few columns (hitting the >> ) , these no longer sort correctly when clicking the variable name.
I tried this in RStudio for Windows ("Cherry Blossom" Release (6e31ffc3, 2023-05-09) for windows) and do not observe this bug.
I taught my students that a way to make sure they have re-ordered a factor correctly (e.g., reordering the Airbag variable to (None, Driver, Driver & Passenger) rather than default alphabetical, they can sort in the Viewer window. However, in some other data sets with more variables, this quick check fails.