changed bubble sort to handle caps