Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort the language listing #113

Merged
merged 2 commits into from
May 14, 2018
Merged

Conversation

rleungx
Copy link
Contributor

@rleungx rleungx commented May 14, 2018

Closes #111.

src/main.rs Outdated
@@ -226,7 +226,8 @@ fn run() -> Result<()> {
let theme = assets.get_theme(config.theme.unwrap_or("Default"))?;

if app.matches.is_present("list-languages") {
let languages = assets.syntax_set.syntaxes();
let mut languages = assets.syntax_set.syntaxes().to_owned();
languages.sort_by(|a, b| a.name.to_uppercase().cmp(&b.name.to_uppercase()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would sort_by_key work here?

Something like

languages.sort_by_key(|s| s.name.to_uppercase())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. And which one do you prefer? How about sort_by_cached_key? See rust-lang/rust#48639.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have to worry about performance here, so I would prefer sort_by_key, since it is easier to read, in my opinion (sort_by_cached_key is also fine, if it's already available in our minimum-required rustc version).

tests/tester.rs Outdated
"tests/snapshots/sample.rs",
&format!("--style={}", style),
])
.args(&["tests/snapshots/sample.rs", &format!("--style={}", style)])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently trying to fix this here: #114

@rleungx rleungx force-pushed the sort-the-language-listing branch from 5f7a2ab to c2df74b Compare May 14, 2018 17:50
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@sharkdp sharkdp merged commit a5de77a into sharkdp:master May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants