Perl Arrays
Tuesday 4th July, 2006 15:49 Comments: 0
I was trying to sort an array of non-unique values into a sorted array of unique values. Originally I sorted it and then compared each key against the next one in the array and added it to an additional temporary array if it was unique and then assigned the new array over the old array. It worked, but it wasn\'t particularly elegant. I used Google and came across this idea, you create a hash based on the array and then output the hash back as a sorted array. I\'ve just replaced a screen length of code with 3 lines. Nice.