Webcore : Best was to sort an array of strings?

I have the playlist below loaded into a string array. I want to add this song to the array.

/storage/25D7-6534/Entire Music Collection/AC DC - Back In Black.mp3

I have considered an insertion-sort. But I could just add the string as the first/last array item and sort the array. Any suggestions on how to sort a string array?

Playlist
/storage/25D7-6534/Entire Music Collection/10,000 Maniacs - These Are Days.mp3
/storage/25D7-6534/Entire Music Collection/5 Seconds of Summer - Amnesia.mp3
/storage/25D7-6534/Entire Music Collection/A Rocket To The Moon - Like We Used To.mp3
/storage/25D7-6534/Entire Music Collection/Air Supply - All Out Of Love.mp3
/storage/25D7-6534/Entire Music Collection/Air Supply - Even The Nights Are Better.mp3
/storage/25D7-6534/Entire Music Collection/Air Supply - Lost In Love.mp3
/storage/25D7-6534/Entire Music Collection/Air Supply - Making Love (Out Of Nothing At All).mp3
/storage/25D7-6534/Entire Music Collection/Alabama - Feels So Right.mp3
/storage/25D7-6534/Entire Music Collection/Andy Gibb - (Our Love) Don't Throw It All Away.mp3
/storage/25D7-6534/Entire Music Collection/Anna Nalick - Breathe.mp3
/storage/25D7-6534/Entire Music Collection/April Wine - Just Between You And Me.mp3
/storage/25D7-6534/Entire Music Collection/A-Teens - Heartbreak Lullaby.mp3
/storage/25D7-6534/Entire Music Collection/A-Teens - Sugar Rush.mp3
/storage/25D7-6534/Entire Music Collection/Aurora - Dreaming.mp3

I’ve had an idea for a while that WC sorts arrays anyway, but maybe that’s just devices?

From my old computer science days, I remember there are varies sort methods, with differing levels of complexity and ease of programming. Probably the easiest to code for a short list is a bubble sort. You run through the array comparing two items e.g 1 & 2, and swapping as appropriate, then do 2 & 3 etc Once completed you start again, and keep repeating until no swaps are made.

I’m curious about what your application is?

Exactly. I have learned/used several sorting methods over the years. But webcore does not technically have an alphabetical text comparison function. Meaning that the comparison would tell me that "AC DC" is before "Air Supply." So I'm not sure how to compare each entry to determine alphabetical sorting. The reason for this task....I have the same "Todd's Favorites" playlist that I use on several different devices...Kodi, my phone, my work phone....etc. Each of those devices have a different directory structure and directory names, different paths, as you will. When I update those playlists, I have to copy and paste at least 3 playlists, one for each device, doing an insertion sort to keep them alphabetical. I am just trying to automate that process and not have to do all of the mindless editing of each of those lists.

Have you ever looked at plex media server? I think this could achieve what you are trying to do (but not sure what your kodi box is connected to)
PMS would index all your media, then you can create playlists, these are held in the PMS server. The plexamp can then access these from all phones, and the plex app on smart Tv;s etc. I think you have to pay for a plex pass to use plex amp.

If you want to do this yourself, gave you considered holding the playlist centrally, then calling out from WC to obtain it? When the programming has got beyond WC’s capabilities, I’ve used Node red. This is very easy to setup and have an app that can handle an http get request from WC. Within node red you can store/sort etc

I did run Plex for a short while. I ONLY do music on my Kodi (or the Plex). We don't use it for video. I have found Kodi on a RPi easy to set up and maintain. I feed music to my whole-home audio system with Kodi. It works well, and the WAF is pretty good. To each his own....

I could host the playlist files on my system and use other means besides WC to edit/sort them. And I could remote into my system with the other devices and download the updated playlists. Just have not pursued that option. I have dabbled with Node Red. Maybe I'll dabble more. I found some Python examples that do exactly what I want, but I have very little experience with Python. But, I was really hoping to complete this task with WC. I would love to see better options within WC for sorting and text comparison. @nh.schottfam

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.