@@ -228,10 +228,9 @@ public static function moodleoverflow_get_reputation($moodleoverflowid, $userid
228
228
/**
229
229
* Sort the answers of a discussion by their marks and votes.
230
230
*
231
- * @param array $posts all the posts from a discussion.
231
+ * @param object $posts all the posts from a discussion.
232
232
*/
233
233
public static function moodleoverflow_sort_answers_by_ratings ($ posts ) {
234
-
235
234
// Create a copy that only has the answer posts and save the parent post.
236
235
$ answerposts = $ posts ;
237
236
$ parentpost = array_shift ($ answerposts );
@@ -848,29 +847,4 @@ private static function moodleoverflow_quicksort_post_by_votes(array &$posts, $l
848
847
}
849
848
}
850
849
851
- private static function moodleoverflow_mergesort_post_by_votes (array &$ posts , $ low , $ high ): array {
852
- $ length = $ high - $ low ;
853
- if ($ length <= 1 ) {
854
- return $ posts ;
855
- }
856
- $ mid = $ low + (int ) ($ length / 2 );
857
-
858
- self ::moodleoverflow_mergesort_post_by_votes ($ posts , $ low , $ mid );
859
- self ::moodleoverflow_mergesort_post_by_votes ($ posts , $ mid + 1 , $ high );
860
- return self ::moodleoverflow_merge_posts ($ post , $ low , $ mid , $ mid +1 , $ high );
861
- }
862
-
863
- private static function moodleoverflow_merge_posts (&$ posts , $ leftlow , $ lefthigh , $ rightlow , $ righthigh ) {
864
- while ($ leftlow <= $ lefthigh && $ rightlow <= $ righthigh ) {
865
- // Sort after votesdifference, then sort after time created.
866
- if ($ posts [$ leftlow ]->votesdifference > $ posts [$ rightlow ]->votesdifference ) {
867
- $ leftlow ++;
868
- } else {
869
- $ value = $ posts [$ rightlow ];
870
- $ index = $ rightlow ;
871
-
872
- //Shift all the element
873
- }
874
- }
875
- }
876
850
}
0 commit comments