I have several numbers in an array and I would like to find the difference between each one and sort by the lowest result (I don't want to repeat items). I tried using the command "perms" since it gets all the permutations
v = [120;124;130];
p = perms(v)
but it doesn't seem to work the way I would like. Does anyone have any other suggestions
Example: I have 3 numbers a=[120,124,130] (please note there could be hundreds of numbers) and it would find the differences between the numbers, then sort by the result. The calculations would look like the text below.
124-120 =4
130-124 =6
130-120 =10
So the final array b will look like the array below
b=
[124 120 4
130 124 6
130 120 10]
PS: I'm using octave 3.8.1 which is like matlab