sortby 0.1.3

adds convenient sort functions for Iterators
Documentation
  • Coverage
  • 12.5%
    1 out of 8 items documented1 out of 7 items with examples
  • Size
  • Source code size: 10.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.27 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • sklose/sortby-rs
    6 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • sklose

Rust Crates

Sort By

Convenience functions that allow for sorting iterators.

Example

use sortby::*;

#[derive(Clone, Debug, Eq, PartialEq)]
struct Person {
  pub age: i32,
  pub name: &'static str,
}

fn main() {
  let data = vec![
    Person {
      name: "Rich",
      age: 18,
    },
    Person {
      name: "Bob",
      age: 9,
    },
    Person {
      name: "Marc",
      age: 21,
    },
    Person {
      name: "Alice",
      age: 18,
    },
  ];

  let sorted: Vec<_> = data.iter()
    .sort_by_desc(|p| p.age)
    .then_sort_by(|p| p.name)
    .collect();

   println!("{:#?}", sorted);
}