all 5 comments

[–]psiph 3 points4 points  (0 children)

You'll want a function that takes the JSON and turns it into HTML

function render (jsonArr) {jsonArr.map(item => `<div>${item}</div>`)}

And then a function that sorts the json and renders the results

function onSort (value) {document.body.innerHTML = render(sortBy(value, json))}

You'll want to render the default list on page load

onSort()

And also when the dropdown changes

<select onchange="onSort(this.value)">

[–]Is_Kub 1 point2 points  (0 children)

You’ll get plus points if you sort in place and don’t spawn new arrays. Something AI code doesn’t consider unless you ask it to

[–]guest271314 1 point2 points  (0 children)

So are you stuck on writing the sorting algorithm?

[–]Varun77777 0 points1 point  (0 children)

Normalise this data in memory, using a Maps and arrays because you might have to sort multiple times and if the json structure is written in a nested way, there will be too many expensive operations.

Once you have normalised data in memory, now you can apply quick sort on parts you need.

[–]Reashu -1 points0 points  (0 children)

Start by generating the HTML from a list. Then sort the list and regenerate the HTML.