From 68733469aeaf1301e40241f2e27d101d046eb13c Mon Sep 17 00:00:00 2001 From: Taka Date: Mon, 15 Jul 2019 05:59:54 +0000 Subject: [PATCH] Sort equally-scored search results by caption. --- src/MainForm.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MainForm.cs b/src/MainForm.cs index 4507cfd..8af72a2 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -140,7 +140,12 @@ public partial class MainForm : Form // sort the search results results.Sort( (lhs, rhs) => { - return (lhs.Item2 == rhs.Item2) ? 0 : (lhs.Item2 > rhs.Item2) ? -1 : +1 ; + if ( lhs.Item2 < rhs.Item2 ) + return +1 ; + else if ( lhs.Item2 > rhs.Item2 ) + return -1 ; + // NOTE: We also sort by caption/filename to handle things like "foo-1" vs. "foo-2". + return String.Compare( lhs.Item1.caption(), rhs.Item1.caption() ) ; } ) ; if ( searchQuery != "" && logger.IsInfoEnabled ) { if ( results.Count > 0 ) {