rust-lang/rust — pull request #16735 by carols10cents (2014-08-24 21:12:02+00:00)
Title: Sort doc search results by their total module path length

Hi! This is my first attempt at a rust contribution (:fireworks:)! I think this could improve the documentation search results.

Using the assumption that more commonly used items are going to be higher in the module hierarchy and have shorter names, I've added a sort using the total module path length where longer will be ranked later. I think this is a good heuristic for more important and more relevant to the person searching the docs.

I've put the docs with my change up here, if you'd like to play with it to see the difference: https://carols10cents.github.io/rustdoc-playground/std/index.html?search=read

Here are some screenshots of search results before and after this change, where before is the nightly docs as of today on rust-lang.org. I haven't been using rust long enough to be able to say this is always going to be the better ranking, but it doesn't seem to make the results in general any worse, and in some cases makes them dramatically better.

![screen_shot_2014-08-24_at_4_41_06_pm](https://cloud.githubusercontent.com/assets/193874/4024595/b3242af2-2bd1-11e4-8365-cbe58311fbd4.png)

![screen_shot_2014-08-24_at_4_41_03_pm](https://cloud.githubusercontent.com/assets/193874/4024597/bee0a280-2bd1-11e4-895b-b25b77e6319b.png)

![screen_shot_2014-08-24_at_4_39_15_pm](https://cloud.githubusercontent.com/assets/193874/4024599/c9e0e9d8-2bd1-11e4-95f7-f23cac517446.png)

![screen_shot_2014-08-24_at_4_39_06_pm](https://cloud.githubusercontent.com/assets/193874/4024603/d85c5844-2bd1-11e4-8994-9205dce024c9.png)

![screen_shot_2014-08-24_at_4_38_56_pm](https://cloud.githubusercontent.com/assets/193874/4024606/e3f7eaec-2bd1-11e4-9a12-4de990599d8a.png)

![screen_shot_2014-08-24_at_4_38_49_pm](https://cloud.githubusercontent.com/assets/193874/4024607/e9a8810e-2bd1-11e4-9419-1de4b8c0db39.png)

An added bonus is that you can see a bit better how the results are being sorted; it just *looks* less random when they're ordered (in groups) shortest to longest.

I'd love to hear what more experienced rust documentation users think!