private List <JSONObject> GetSongListFromResults(JSONNode result, string SearchString, ref string errorMessage, SongFilter filter = SongFilter.All, string sortby = "-rating", int reverse = 1) { List <JSONObject> songs = new List <JSONObject>(); if (result != null) { // Add query results to out song database. if (result["docs"].IsArray) { var downloadedsongs = result["docs"].AsArray; for (int i = 0; i < downloadedsongs.Count; i++) { new SongMap(downloadedsongs[i].AsObject); } foreach (JSONObject currentSong in result["docs"].AsArray) { new SongMap(currentSong); } } else { new SongMap(result.AsObject); } } var list = MapDatabase.Search(SearchString); try { string[] sortorder = sortby.Split(' '); list.Sort(delegate(SongMap c1, SongMap c2) { return(reverse * CompareSong(c1.song, c2.song, ref sortorder)); }); } catch (Exception e) { //QueueChatMessage($"Exception {e} sorting song list"); Plugin.Log($"Exception sorting a returned song list. {e.ToString()}"); } foreach (var song in list) { errorMessage = SongSearchFilter(song.song, false, filter); if (errorMessage == "") { songs.Add(song.song); } } return(songs); }