[Solved] Array comparison and sorting to list c#

Try this: // assuming you’ll already have the subjects of the emails var subjects = new List<string> { “ABC / Vesse / 11371503 /C report”, “Value/BEY/11371503/A report” }; var listOfItems = new List<Tuple<string, string, int, string>>(); subjects.ForEach(s => { var splits = s.Split(new[] {“https://stackoverflow.com/”}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); // Do proper error checking before the int.Parse … Read more

[Solved] Shuffle character array in C

Having char names[16][20] = …; char randomnames[16][20]; you cannot do randomnames[i] = names[j]; but char names[16][20] = …; char * randomnames[16]; … randomnames[i] = names[j]; or char names[16][20] = …; char randomnames[16][20]; … strcpy(randomnames[i], names[j]); Warning when I see your first version of the question you have to print names rather than randomnames, that means … Read more

[Solved] Sort Multi-Dimensional Array PHP

If I understand what you need to do, you can use usort: usort($array, function($a, $b) { $sort = array(‘Red’, ‘Green’, ‘Blue’); if (array_search($a[‘House_Colour’], $sort) > array_search($b[‘House_Colour’], $sort)) return 1; if (array_search($a[‘House_Colour’], $sort) < array_search($b[‘House_Colour’], $sort)) return -1; return 0; }); If you can leverage on defines instead on relying on strings for the house colors … Read more

[Solved] Sort mixed text lines (alphanum) in Perl

The Schwartzian Transform as suggested in Toto’s answer is probably the fastest way to sort your lines here. But you said you’re a Perl newbie, and I like to show how the lines can be sorted traditionally. Perl has a sort function that sorts a list simply by alphabet. But you can supply a custom … Read more

[Solved] Sorting a list based on associated scores [closed]

I would approach this as follows: from collections import defaultdict # using defaultdict makes the sums easier correlations = defaultdict(int) # default to int (i.e. 0) for i1, i2, correl in strScoresDict: # loop through data correlations[i1] += correl # add score for first item correlations[i2] += correl # and second item output = sorted(correlations, … Read more

[Solved] TCL Sort program without using lsort [closed]

While we won’t give you the answer, we can suggest a few useful things. For example, you compare two elements of a list (at $idx1 and $idx2) with this: string compare [lindex $theList $idx1] [lindex $theList $idx2] And you might use this procedure to swap those two elements: proc swap {nameOfListVar idx1 idx2} { upvar … Read more

[Solved] Print array values

if you want to sort according to values in desc order $finalprint[] = “XYZ”; $finalprint[] = “ABC”; $finalprint[] = “MNO”; rsort($finalprint); foreach ($finalprint as $val) { echo $val.”&nbsp;” ; } o/p XYZ MNO ABC if you want to sort according to keys in desc order krsort($finalprint); foreach ($finalprint as $val) { echo $val.”&nbsp;” ; } … Read more