Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Deprecate msort #1752

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,15 @@ function getTerms($connection2, $gibbonSchoolYearID, $short = false)
return $output;
}

//Array sort for multidimensional arrays
/**
* Array sort for multidimensional arrays.
*
* Deprecated in favor of native usort.
*
* @since 2013
* @version v12.0.00
* @deprecated v26.0.00
*/
function msort($array, $id = 'id', $sort_ascending = true)
{
$temp_array = array();
Expand Down
3 changes: 2 additions & 1 deletion modules/Planner/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ function getResourcesTagCloud($guid, $connection2, $tagCount = 50) {
++$count;
}

$tags = msort($tags, 0, true);
// Sort tags by the value of their tag name (i.e. key=0) asecendingly.
usort($tags, fn($a, $b) => $a[0] <=> $b[0]);

$min_font_size = 16;
$max_font_size = 30;
Expand Down
4 changes: 3 additions & 1 deletion modules/Timetable/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,9 @@ function renderTT($guid, $connection2, $gibbonPersonID, $gibbonTTID, $title = ''
$eventsCombined = $eventsPersonal;
}

$eventsCombined = msort($eventsCombined, 2, true);
// Sort $eventsCombined by the value of their start timestamp (key = 2) ascendingly.
// See getCalendarEvents() for field details of each events.
usort($eventsCombined, fn($a, $b) => $a[2] <=> $b[2]);

$currentAllDays = 0;
$lastDate = '';
Expand Down