slice::sort_by_key is a thin wrapper around “real” sort function, it requires key extraction function to return
B and not
&B, so if
key is not
Copy you have to use
slice::sort_by instead. See https://play.rust-lang.org/?gist=eea7cb6f6d574403392d630ce4f2a495&version=stable for an example.
What is the reason behind this design? Thank you!