@@ -194,7 +194,7 @@ import '@nextcloud/dialogs/style.css'
194194import  Vue , { defineComponent  } from  ' vue' 
195195
196196import  { emit , subscribe , unsubscribe  } from  ' @nextcloud/event-bus' 
197- import  { File  as  NcFile , Node , davRemoteURL , davRootPath , davGetRootPath  } from  ' @nextcloud/files' 
197+ import  { File  as  NcFile , Node , davRemoteURL , davRootPath , davGetRootPath ,  sortNodes  } from  ' @nextcloud/files' 
198198import  { loadState  } from  ' @nextcloud/initial-state' 
199199import  { showError  } from  ' @nextcloud/dialogs' 
200200import  axios  from  ' @nextcloud/axios' 
@@ -203,7 +203,7 @@ import getSortingConfig from '../services/FileSortingConfig.ts'
203203import  isFullscreen  from  ' @nextcloud/vue/dist/Mixins/isFullscreen.js' 
204204import  isMobile  from  ' @nextcloud/vue/dist/Mixins/isMobile.js' 
205205
206- import  { extractFilePaths , sortCompare ,  extractFilePathFromSource  } from  ' ../utils/fileUtils.ts' 
206+ import  { extractFilePaths , extractFilePathFromSource  } from  ' ../utils/fileUtils.ts' 
207207import  cancelableRequest  from  ' ../utils/CancelableRequest.js' 
208208import  canDownload  from  ' ../utils/canDownload.js' 
209209import  Error  from  ' ../components/Error.vue' 
@@ -762,7 +762,23 @@ export default defineComponent({
762762				//  sort like the files list 
763763				//  TODO: implement global sorting API 
764764				//  https://github.com/nextcloud/server/blob/a83b79c5f8ab20ed9b4d751167417a65fa3c42b8/apps/files/lib/Controller/ApiController.php#L247 
765- 				this .fileList  =  filteredFiles .sort ((a , b ) =>  sortCompare (a, b, this .sortingConfig .key , this .sortingConfig .asc )) 
765+ 				const  url  =  this .currentFile .source  ??  this .currentFile .davPath  
766+ 				const  nodes  =  filteredFiles .map ( 
767+ 					file  =>  new  NcFile ({ 
768+ 						source:  davRemoteURL +  davGetRootPath () +  file .filename , 
769+ 						fileid:  file .fileid , 
770+ 						displayname:  file .displayname , 
771+ 						mime:  file .mime , 
772+ 						mtime:  new  Date (file .lastmod ), 
773+ 						owner:  this .currentFile .ownerId , 
774+ 						root:  url .includes (' remote.php/dav' ?  davGetRootPath () :  undefined , 
775+ 					}), 
776+ 				) 
777+ 				const  sortedNodes  =  sortNodes (nodes, { 
778+ 					sortingMode:  this .sortingConfig .key , 
779+ 					sortingOrder:  this .sortingConfig .asc  ?  ' asc' :  ' desc'  
780+ 				}) 
781+ 				this .fileList  =  sortedNodes .map (node  =>  filteredFiles .find (file  =>  file .filename  ===  node .path )) 
766782
767783				//  store current position 
768784				this .currentIndex  =  this .fileList .findIndex (file  =>  file .filename  ===  fileInfo .filename ) 
0 commit comments