use unstable sort
This commit is contained in:
parent
4192d37854
commit
a2ce336fe7
1 changed files with 12 additions and 4 deletions
|
@ -136,12 +136,12 @@ pub trait FormatSteps {
|
||||||
|
|
||||||
// sort errors so unreadable files appear before files with unknown mimetypes - ScanError impls Ord such that
|
// sort errors so unreadable files appear before files with unknown mimetypes - ScanError impls Ord such that
|
||||||
// ScanError::File > ScanError::Mime
|
// ScanError::File > ScanError::Mime
|
||||||
let errors = entries.iter().filter_map(|e| e.as_ref().err()).sorted();
|
let errors = entries.iter().filter_map(|e| e.as_ref().err()).sorted_unstable();
|
||||||
// sort files so that files with no known extension come before those with known extensions - None > Some("jpg")
|
// sort files so that files with no known extension come before those with known extensions - None > Some("jpg")
|
||||||
let findings = entries
|
let findings = entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|e| e.as_ref().ok())
|
.filter_map(|e| e.as_ref().ok())
|
||||||
.sorted_by(|a, b| b.recommended_extension().cmp(&a.recommended_extension()).reverse());
|
.sorted_unstable_by(|a, b| b.recommended_extension().cmp(&a.recommended_extension()).reverse());
|
||||||
|
|
||||||
for error in errors {
|
for error in errors {
|
||||||
match error {
|
match error {
|
||||||
|
@ -343,8 +343,16 @@ impl Format for Json {
|
||||||
let result = serde_json::to_writer_pretty(
|
let result = serde_json::to_writer_pretty(
|
||||||
f,
|
f,
|
||||||
&SerdeEntries {
|
&SerdeEntries {
|
||||||
errors: &entries.iter().filter_map(|e| e.as_ref().err()).sorted().collect(),
|
errors: &entries
|
||||||
findings: &entries.iter().filter_map(|f| f.as_ref().ok()).sorted().collect(),
|
.iter()
|
||||||
|
.filter_map(|e| e.as_ref().err())
|
||||||
|
.sorted_unstable()
|
||||||
|
.collect(),
|
||||||
|
findings: &entries
|
||||||
|
.iter()
|
||||||
|
.filter_map(|f| f.as_ref().ok())
|
||||||
|
.sorted_unstable()
|
||||||
|
.collect(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue