
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Helpful functionality for sorting and comparing.
gem install sorting
Sort a list of Person objects
# Convenient
require 'sorting/convenience'
people.sort_by { |person| [asc(person.first_name), asc(person.last_name), desc(person.age)] }
# Or without patching Kernel
require 'sorting'
people.sort_by { |person|
[Sorting.asc(person.first_name), Sorting.asc(person.last_name), Sorting.desc(person.age)]
}
# Care about expensive comparison values which may not always be needed
# assume item.expensive_value takes a lot of time to compute, but since it's the second value,
# it might only be needed in a small number of cases.
require 'sorting/convenience'
items.sort_by { |item|
[asc(item.cheap_value), asc(:nils_last) { item.expensive_value }]
}
# Care about nil values in your data
require 'sorting/convenience'
people.sort_by { |person|
[asc(person.first_name, :nils_first), asc(person.first_name, :nils_last)]
}
# Only care about nil values in your data
[5,3,nil,9].sort_by { |x| x || Sorting::Bigger } # Sorting::Smaller is available too
Take a look at {file:documentation/examples.rb} for more examples.
You can use this code under the {file:LICENSE.txt BSD-2-Clause License}, free of charge. If you need a different license, please ask the author.
FAQs
Unknown package
We found that sorting demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.