@@ -686,13 +686,22 @@ function refreshLibrary(options) {
686
686
console . warn ( "Unknown search type " + searchType , searchValue ) ;
687
687
}
688
688
// 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 ) ;
690
699
}
691
700
// if not otherwise sorted, use 'sort by' option
692
701
if ( ! sortedByRelevance )
693
702
visibleApps . sort ( appSorter ) ;
694
703
695
- if ( activeSort && ! searchValue ) { // only sort if not searching (searching already sorts)
704
+ if ( activeSort && ! sortedByRelevance ) { // only sort if not searching (searching already sorts)
696
705
if ( [ "created" , "modified" , "installs" , "favourites" ] . includes ( activeSort ) ) {
697
706
visibleApps = visibleApps . sort ( ( a , b ) =>
698
707
( ( appSortInfo [ b . id ] || { } ) [ activeSort ] || 0 ) -
0 commit comments