I have an array of 16-elements (each element is 16-bits long), and I wish to find the minimum entry in the array, return the minimum, and re-arrange all the entries in the array that come after the minimum so that the array is one contiguous block of entries. I know I have to use a comparator, but I really have no idea where to start with regards to comparing a large group of numbers and determining the minimum.
I'm actually making is a priority queue. I have the queue functionality implemented, but instead of returning what's at the head of the queue, I want to return the entry with the smallest value, and keep the storage contiguous.
e.g. {2,3,4,1,5,6,-,-}
min is 1 --> {2,3,4,-,5,6,-,-}
Rearrange so everything following the returned min is moved to the index preceding it-->
{2,3,4,5,6,-,-,-}