File tree Expand file tree Collapse file tree 5 files changed +5
-5
lines changed Expand file tree Collapse file tree 5 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export default class BubbleSort extends Sort {
55 // Flag that holds info about whether the swap has occur or not.
66 let swapped = false ;
77 // Clone original array to prevent its modification.
8- const array = originalArray . slice ( 0 ) ;
8+ const array = [ ... originalArray ] ;
99
1010 for ( let i = 0 ; i < array . length ; i += 1 ) {
1111 swapped = false ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Sort from '../Sort';
22
33export default class InsertionSort extends Sort {
44 sort ( originalArray ) {
5- const array = originalArray . slice ( 0 ) ;
5+ const array = [ ... originalArray ] ;
66
77 // Go through all array elements...
88 for ( let i = 0 ; i < array . length ; i += 1 ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Sort from '../Sort';
33export default class QuickSort extends Sort {
44 sort ( originalArray ) {
55 // Clone original array to prevent it from modification.
6- const array = originalArray . slice ( 0 ) ;
6+ const array = [ ... originalArray ] ;
77
88 // If array has less then or equal to one elements then it is already sorted.
99 if ( array . length <= 1 ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Sort from '../Sort';
33export default class SelectionSort extends Sort {
44 sort ( originalArray ) {
55 // Clone original array to prevent its modification.
6- const array = originalArray . slice ( 0 ) ;
6+ const array = [ ... originalArray ] ;
77
88 for ( let i = 0 ; i < array . length - 1 ; i += 1 ) {
99 let minIndex = i ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Sort from '../Sort';
33export default class ShellSort extends Sort {
44 sort ( originalArray ) {
55 // Prevent original array from mutations.
6- const array = originalArray . slice ( 0 ) ;
6+ const array = [ ... originalArray ] ;
77
88 // Define a gap distance.
99 let gap = Math . floor ( array . length / 2 ) ;
You can’t perform that action at this time.
0 commit comments