Browse Source

refactor to use `sort_by_key` and `reverse`

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
remotes/origin/list-filter
Ryan Cao 1 year ago
parent
commit
84523ef430
No known key found for this signature in database
  1. 7
      src/remote_node_index.rs

7
src/remote_node_index.rs

@ -89,10 +89,9 @@ pub fn list( @@ -89,10 +89,9 @@ pub fn list(
let resp = crate::http::get(&index_json_url)?;
let mut value: Vec<IndexedNodeVersion> = resp.json()?;
if *sort == SortingMethod::Ascending {
value.sort_by(|a, b| a.version.cmp(&b.version));
} else {
value.sort_by(|a, b| b.version.cmp(&a.version));
value.sort_by_key(|v| v.version.clone());
if let SortingMethod::Descending = sort {
value.reverse();
}
Ok(value)

Loading…
Cancel
Save