Skip to content

Instantly share code, notes, and snippets.

@vaidehijoshi
Last active June 20, 2017 16:13
Show Gist options
  • Save vaidehijoshi/b2208657606109909762a4b6932a5762 to your computer and use it in GitHub Desktop.
Save vaidehijoshi/b2208657606109909762a4b6932a5762 to your computer and use it in GitHub Desktop.
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