Skip to content

Commit a29a012

Browse files
committed
fix ordering
1 parent daf3aa2 commit a29a012

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/html/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use deno_ast::ModuleSpecifier;
22
use handlebars::handlebars_helper;
33
use handlebars::Handlebars;
44
use indexmap::IndexMap;
5+
use std::cmp::Ordering;
56
use std::collections::HashMap;
67
use std::path::PathBuf;
78
use std::rc::Rc;
@@ -161,7 +162,7 @@ impl<'ctx> GenerateCtx<'ctx> {
161162
}
162163
}
163164

164-
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
165+
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
165166
pub struct ShortPath {
166167
pub path: String,
167168
pub specifier: ModuleSpecifier,
@@ -244,6 +245,21 @@ impl ShortPath {
244245
}
245246
}
246247

248+
impl Ord for ShortPath {
249+
fn cmp(&self, other: &Self) -> Ordering {
250+
self
251+
.is_main
252+
.cmp(&other.is_main)
253+
.then_with(|| self.display_name().cmp(&other.display_name()))
254+
}
255+
}
256+
257+
impl PartialOrd for ShortPath {
258+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
259+
Some(self.cmp(other))
260+
}
261+
}
262+
247263
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
248264
pub enum DocNodeKindWithDrilldown {
249265
Property,

src/html/partition.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,13 @@ pub fn partition_nodes_by_entrypoint(
264264
flatten_namespaces,
265265
);
266266

267-
for (_kind, nodes) in partitions.iter_mut() {
268-
nodes.sort_by_key(|n| n.get_name().to_string());
267+
for (_file, nodes) in partitions.iter_mut() {
268+
nodes.sort_by(compare_node);
269269
}
270270

271+
partitions.sort_keys();
272+
271273
partitions
272-
.sorted_by(|key1, _value1, key2, _value2| {
273-
key1
274-
.is_main
275-
.cmp(&key2.is_main)
276-
.then_with(|| key1.display_name().cmp(&key2.display_name()))
277-
})
278-
.collect()
279274
}
280275

281276
fn compare_node(
@@ -298,9 +293,11 @@ fn compare_node(
298293
.then_with(|| {
299294
node1
300295
.get_name()
301-
.cmp(node2.get_name())
302-
.then_with(|| node1.kind.cmp(&node2.kind))
296+
.to_ascii_lowercase()
297+
.cmp(&node2.get_name().to_ascii_lowercase())
303298
})
299+
.then_with(|| node1.get_name().cmp(node2.get_name()))
300+
.then_with(|| node1.kind.cmp(&node2.kind))
304301
}
305302

306303
pub fn get_partitions_for_file(

0 commit comments

Comments
 (0)