Inserting an element into an array, and then sorting the array