@@ -686,13 +686,22 @@ function refreshLibrary(options) {
686686 console . warn ( "Unknown search type " + searchType , searchValue ) ;
687687 }
688688 // Now finally, filter, sort based on relevance and set the search result
689- visibleApps = searchResult . filter ( a => a . relevance > 0 ) . sort ( ( a , b ) => ( b . relevance - ( 0 | b . sortorder ) ) - ( a . relevance - ( 0 | a . sortorder ) ) ) . map ( a => a . app ) ;
689+ visibleApps = searchResult . filter ( a => a . relevance > 0 ) . sort ( ( a , b ) => {
690+ // sort by relevance and sort order
691+ let sort = ( b . relevance - ( 0 | b . sortorder ) ) - ( a . relevance - ( 0 | a . sortorder ) ) ;
692+ if ( sort ) return sort ;
693+ // if relevance is the same, sort by extraSort (eg created, modified, installs, favourites)
694+ if ( [ "created" , "modified" , "installs" , "favourites" ] . includes ( activeSort ) )
695+ return ( ( appSortInfo [ b . app . id ] || { } ) [ activeSort ] || 0 ) -
696+ ( ( appSortInfo [ a . app . id ] || { } ) [ activeSort ] || 0 ) ;
697+ return 0 ;
698+ } ) . map ( a => a . app ) ;
690699 }
691700 // if not otherwise sorted, use 'sort by' option
692701 if ( ! sortedByRelevance )
693702 visibleApps . sort ( appSorter ) ;
694703
695- if ( activeSort && ! searchValue ) { // only sort if not searching (searching already sorts)
704+ if ( activeSort && ! sortedByRelevance ) { // only sort if not searching (searching already sorts)
696705 if ( [ "created" , "modified" , "installs" , "favourites" ] . includes ( activeSort ) ) {
697706 visibleApps = visibleApps . sort ( ( a , b ) =>
698707 ( ( appSortInfo [ b . id ] || { } ) [ activeSort ] || 0 ) -
0 commit comments