iolivia / rust-sokoban

Rust Sokoban book and code samples
https://sokoban.iolivia.me
MIT License
155 stars 29 forks source link

use `sort_by_key` to improve readabilty #66

Closed hellow554 closed 4 years ago

hellow554 commented 4 years ago

https://github.com/iolivia/rust-sokoban/blob/5e1ac13664d739c21af680fa7fa63b690f53aa92/code/rust-sokoban-c01-04/src/main.rs#L65

At first I thought: you could just use cmp instead of partial_cmp.unwrap but then at the second look, why don't you just use sort_by_key (or better sort_unstable_key_by which will improve performance for large slices because of the underlying sorting algorithmn)

iolivia commented 4 years ago

great suggestion, thank you @hellow554!