Today I had a challenge I had to sort a data in my Svelte app so to start let’s import and Jason from a local storage.

First visit this page and install json import tool
https://www.devsamples.com/javascript/svelte/using-local-json-files-in-svelte-files

Put your json under src folder and type something like this in your main App.svelte file.

There is a time when we are wondering how to start sorting or Json and to answer the simple question there is only one solution just use JavaScript cause why not basically JavaScript is the best front solution for sorting your data. So, in my case I had to create an front for sorting the videos and my video Json wasn’t really provided as perfect as possible so I had to search the data and here how you can do that basically just by use of sort function.

More here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

And the sorting code here: