I am so new to maple and I dont know what to do exactly! I have 10 numbers, for finding k nearest number to any of this number I need to keep distances between all numbers and sort them, based on these distances I can get which x is the nearest x to current number so:
for i from 1 to 10 do
for j from 1 to 10 do
dist[j] := abs(x[i]-x[j]);
result[i,j] := abs(x[i]-x[j]);
end do;
end do;
for h from 1 to 10 do
for k from 1 to 10 do
arr[k] := result[h,k];
end do;
distances := (quicksort(arr,1,10));
for t from 1 to 10 do
sortedMatrix[h,t] := distances[t];
end do;
end do;
print(sortedMatrix);
Now I have distances and a number, but i dont know what the other number is?