source-listing example sorts by version

This commit is contained in:
Chris West (Faux) 2017-07-20 12:59:21 +01:00
parent 77918dcee7
commit f8d5c5370b

View File

@ -36,11 +36,11 @@ fn main() {
let archive_filter = env::args().nth(1);
let mut cache = Cache::get_singleton();
let mut source_versions = HashMap::new();
{
let mut all_packages = cache.iter();
let mut source_versions = HashMap::new();
while let Some(binary) = all_packages.next() {
let mut binary_versions = binary.versions();
while let Some(version) = binary_versions.next() {
if let Some(ref target_archive) = archive_filter {
@ -59,9 +59,12 @@ fn main() {
.insert(version.source_version());
}
}
}
for src in lexicographic_sort(source_versions.keys()) {
for ver in lexicographic_sort(source_versions[src].iter()) {
let mut sorted_versions: Vec<&String> = source_versions[src].iter().collect();
sorted_versions.sort_by(|left, right| cache.compare_versions(left, right));
for ver in sorted_versions {
println!("{}={}", src, ver);
}
}