Sriker Ch Sriker Ch - 1 year ago 96
Javascript Question

Filtering in JavaScript or jQuery

I am trying to take the data from the JSON file (link to file).
If I have to sort by the name or by the year of release, how to filter
the contents in that 2D array.

Can anyone please help me to sort this out.

Answer Source

Using jQuery.get() to get your api response, and than sort using Array.prototype.sort().

Sort by Year:

$.get("", (result) => {
    result.Search.sort((a, b, by) => {
        return a.Year < b.Year ? -1 : a.Year > b.Year ? 1 : 0;
<script src=""></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download