source: frontend/node_modules/css-declaration-sorter/src/bubble-sort.mjs

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 409 bytes
Line 
1export function bubbleSort (list, comparator) {
2 let upperIndex = list.length - 1;
3
4 while (upperIndex > 0) {
5 let swapIndex = 0;
6
7 for (let i = 0; i < upperIndex; i += 1) {
8 if (comparator(list[i], list[i + 1]) > 0) {
9 const temp = list[i + 1];
10 list[i + 1] = list[i];
11 list[i] = temp;
12 swapIndex = i;
13 }
14 }
15
16 upperIndex = swapIndex;
17 }
18
19 return list;
20}
Note: See TracBrowser for help on using the repository browser.