15,501,490 members
Home / Discussions / Algorithms

# Algorithms

 Re: Efficiently sort the following? arnold_w24-Aug-17 11:48 arnold_w 24-Aug-17 11:48
 Re: Efficiently sort the following? Richard MacCutchan24-Aug-17 22:05 Richard MacCutchan 24-Aug-17 22:05
 Re: Efficiently sort the following? Richard Deeming25-Aug-17 2:47 Richard Deeming 25-Aug-17 2:47
 Re: Efficiently sort the following? arnold_w28-Aug-17 1:40 arnold_w 28-Aug-17 1:40
 Re: Efficiently sort the following? Richard Deeming29-Aug-17 2:53 Richard Deeming 29-Aug-17 2:53
 Re: Efficiently sort the following? arnold_w30-Aug-17 5:04 arnold_w 30-Aug-17 5:04
 Re: Efficiently sort the following? Richard Deeming30-Aug-17 5:40 Richard Deeming 30-Aug-17 5:40
 Re: Efficiently sort the following? Alan N30-Aug-17 6:48 Alan N 30-Aug-17 6:48
 Let's do this the old way! Sorting on multiple keys with a comparer method is straightforward (and easy to understand?). It is just a nested set of comparisons, compare the first key, if equal compare the second key, etc. For example let's say we have a list of strings and we want a custom sort. 1) by string length 2) alphabetically within each group of equal length The comparer method is C# ```private static Int32 SortByLengthThenAlpha(String x, String y) { // 1st sort Int32 result = x.Length.CompareTo(y.Length); // result will be < 0, 0, > 0 if (result == 0) { // 2nd Sort, standard string sort result = x.CompareTo(y); // and so on if more is needed // if (result==0) { // } // } return result; }``` With an array of strings we can perform the sort with C# `Array.Sort(strings, SortByLengthThenAlpha);` ```Original Order ============== Reddish Yellowish Redder Greenish Red Orange Yellow Orangy Green Sorted ====== Red Green Orange Orangy Redder Yellow Reddish Greenish Yellowish``` Hope that helps explain the general idea. In your case the keys are the numeric values of T, H and L. Alan.
 Re: Efficiently sort the following? arnold_w1-Sep-17 0:50 arnold_w 1-Sep-17 0:50
 Re: Efficiently sort the following? Alan N3-Sep-17 2:13 Alan N 3-Sep-17 2:13
 Re: Efficiently sort the following? arnold_w3-Sep-17 3:37 arnold_w 3-Sep-17 3:37
 How to use tensorflow in c# delphix518-Jul-17 1:48 delphix5 18-Jul-17 1:48
 Re: How to use tensorflow in c# Richard MacCutchan18-Jul-17 3:09 Richard MacCutchan 18-Jul-17 3:09
 C++ algorithm Question Member 1310646721-Jun-17 19:29 Member 13106467 21-Jun-17 19:29
 Re: C++ algorithm Question OriginalGriff21-Jun-17 19:37 OriginalGriff 21-Jun-17 19:37
 Invoice / Payments history table or statement of account Bastien Vandamme14-Jun-17 16:50 Bastien Vandamme 14-Jun-17 16:50
 Re: Invoice / Payments history table or statement of account Gerry Schmitz14-Jun-17 17:17 Gerry Schmitz 14-Jun-17 17:17
 Re: Invoice / Payments history table or statement of account Bastien Vandamme14-Jun-17 17:46 Bastien Vandamme 14-Jun-17 17:46
 Re: Invoice / Payments history table or statement of account Gerry Schmitz14-Jun-17 18:39 Gerry Schmitz 14-Jun-17 18:39
 Re: Invoice / Payments history table or statement of account jschell10-Jul-17 5:30 jschell 10-Jul-17 5:30
 Chaotic image encryption algorithm by Xingyuan Wang Member 1325934114-Jun-17 5:53 Member 13259341 14-Jun-17 5:53
 Selecting values from list to make up totals in second list Wayne Gaylard15-May-17 22:45 Wayne Gaylard 15-May-17 22:45
 Re: Selecting values from list to make up totals in second list Richard MacCutchan15-May-17 23:27 Richard MacCutchan 15-May-17 23:27
 Re: Selecting values from list to make up totals in second list Wayne Gaylard15-May-17 23:34 Wayne Gaylard 15-May-17 23:34
 Re: Selecting values from list to make up totals in second list F-ES Sitecore22-May-17 5:48 F-ES Sitecore 22-May-17 5:48
 Last Visit: 31-Dec-99 19:00     Last Update: 29-Nov-22 3:38 Refresh ᐊ Prev1...21222324252627282930 Next ᐅ