small refactor in bubble sort for better readablity

This commit is contained in:
Peter Shershov 2018-05-23 23:37:14 +03:00
parent 3e0ac7486c
commit 488b7a4c0e
No known key found for this signature in database
GPG Key ID: 1C9BCC58B6BE05DB
2 changed files with 4266 additions and 1 deletions

View File

@ -5,7 +5,7 @@ export default class BubbleSort extends Sort {
// Flag that holds info about whether the swap has occur or not. // Flag that holds info about whether the swap has occur or not.
let swapped = false; let swapped = false;
// Clone original array to prevent its modification. // Clone original array to prevent its modification.
const array = originalArray.slice(0); const array = [...originalArray];
for (let i = 0; i < array.length; i += 1) { for (let i = 0; i < array.length; i += 1) {
swapped = false; swapped = false;

4265
yarn.lock Normal file

File diff suppressed because it is too large Load Diff