Correct text output & sort results by rank

This commit is contained in:
Starbeamrainbowlabs 2018-09-22 12:58:14 +01:00
parent c450051218
commit 53e4403356
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 4 additions and 4 deletions

View file

@ -124,7 +124,7 @@ namespace LibSearchBox
});
List<SearchResult> results = new List<SearchResult>(resultsRaw.AsEnumerable());
results.OrderBy((SearchResult result) => result.Rank);
results.Sort((SearchResult a, SearchResult b) => (int)Math.Round(b.Rank - a.Rank));
return results;
}

View file

@ -35,9 +35,9 @@ namespace LibSearchBox
public override string ToString()
{
StringBuilder result = new StringBuilder();
result.AppendLine($"{Rank.ToString().PadLeft(5)}: {PageName}");
result.Append($" {string.Join(", ", Offsets.Select((SearchOffset nextOffset) => $"{nextOffset.Term} @ {nextOffset.Offset}"))}");
return base.ToString();
result.AppendLine($"{PageName} - ({Rank} points)");
result.Append($" {string.Join(", ", Offsets.Select((SearchOffset nextOffset) => $"{nextOffset.Offset}:{nextOffset.Term}"))}");
return result.ToString();
}
}
}