In the Custom Sort page, it's possible to implement a custom sort algorithm and visualize it using the following APIs.
REQUIREMENTS
Array of DOM element objects
.undefined
.VISUALIZATION FUNCTIONS
You can use the following functions to visualize the sorting algorithm. Asyncronous functions must be called using the await
keyword.
getValue(element)
DOM object
, given its index or the object.element : Number or DOM element
Number : Value of the DOM element
await updateBox(elements, [index1], [index2], [index3])
DOM elements
to red, green and blue respectively given their indexes and plays sounds if any index is specified.
Call this function after every update to the elements array.elements : Array of DOM elements
index1 : Number
index2 : Number
index3 : Number
undefined
await swap(index1, index2)
DOM elements
given their indices, with visualization. No need to call await updateBox
after.index1 : Number
index2 : Number
undefined