sort => sort! on new array
Merge pull request #10543 from vipulnsward/to_sort

Can you improve the commit message a little bit? It's good to describe why the change is happening.