From 69c24daa13c13288d8c6f21ea3f5ea36958e2ff2 Mon Sep 17 00:00:00 2001 From: Maxime Gervais Date: Mon, 12 Feb 2024 17:12:12 +0100 Subject: [PATCH] Cocoa GUI: Fix unsorted streams in compare view Signed-off-by: Maxime Gervais --- Source/GUI/Cocoa/CompareView.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/GUI/Cocoa/CompareView.m b/Source/GUI/Cocoa/CompareView.m index 094e763ba..6e408daf1 100644 --- a/Source/GUI/Cocoa/CompareView.m +++ b/Source/GUI/Cocoa/CompareView.m @@ -235,9 +235,17 @@ -(id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id) } } } - else { - if (index < [_fields count]) - return [[_fields allKeys] objectAtIndex: index]; + else if (index < [_fields count]) { + return [[[_fields allKeys] sortedArrayUsingComparator:^NSComparisonResult(id first, id second) { + if ([first[@"kind"] isLessThan: second[@"kind"]] || ([first[@"kind"] isEqualTo: second[@"kind"]] && [first[@"number"] isLessThan: second[@"number"]])) { + return NSOrderedAscending; + } + if ([first[@"kind"] isGreaterThan: second[@"kind"]] || ([first[@"kind"] isEqualTo: second[@"kind"]] && [first[@"number"] isGreaterThan: second[@"number"]])) { + return NSOrderedDescending; + } + + return NSOrderedSame; + }] objectAtIndex:index]; } return nil;