This sorts the result on Special:FileDuplicateSearch, which is unsorted,
when merged from different repos.
Adding File::compare similar to Title::compare for this
Change-Id: I32e8be92c6067f9e13f3ecd1039c337b0fc3e840
'image',
LocalFile::selectFields(),
array( 'img_sha1' => $hash ),
- __METHOD__
+ __METHOD__,
+ array( 'ORDER BY' => 'img_name' )
);
$result = array();
foreach ( $this->foreignRepos as $repo ) {
$result = array_merge( $result, $repo->findBySha1( $hash ) );
}
+ usort( $result, 'File::compare' );
return $result;
}
}
}
+ /**
+ * Callback for usort() to do file sorts by title
+ *
+ * @param $a File
+ * @param $b File
+ *
+ * @return Integer: result of title comparison
+ */
+ public static function compare( File $a, File $b ) {
+ return Title::compare( $a->getTitle(), $b->getTitle() );
+ }
+
/**
* Return the name of this file
*