Bubble Sort

语言

Implement a function that performs a bubble sort. The function should take in an array of integers and return an array with the integers sorted in ascending order. The input array is modified.

Examples

bubbleSort([9, 3, 6, 2, 1, 11]); // [1, 2, 3, 6, 9, 11]
bubbleSort([12, 16, 14, 1, 2, 3]); // [1, 2, 3, 12, 14, 16]

Hints

新

加载编辑器

    Bubble Sort | 算法面试题及解决方案