Last active
June 20, 2017 16:13
-
-
Save vaidehijoshi/b2208657606109909762a4b6932a5762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function swap(items, leftPointerIndex, rightPointerIndex){ | |
// Create a temporary reference for the left item. | |
var tempReference = items[leftPointerIndex]; | |
// Move left item to the index that contains right item. | |
// Move right item to the temporary reference. | |
items[leftPointerIndex] = items[rightPointerIndex]; | |
items[rightPointerIndex] = tempReference; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment