Using new sort algorithm as bubble sort is inefficient. Fixes array out of bounds errors.