MySQL ORDER BY
SELECT
select_list
FROM
table_name
ORDER BY
column1 [ASC|DESC],
column2 [ASC|DESC],
...;
MySQL ORDER BY
SELECT
select_list
FROM
table_name
ORDER BY
column1 [ASC|DESC],
column2 [ASC|DESC],
...;
array sort php
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo $val;
}
/*
OUTPUT:
apple
banana
lemon
orange
*/
?>
php array sort
function aasort (&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
aasort($your_array,"order");
php array sort
// Fonction de comparaison
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
array sort php
// array sort php
$room_details = array(
"2020-09-27": [
{
"content": "how are you",
"detail_id": "1",
"time": "17:57:28",
"chat_time": "2020-09-24 17:57:28",
"width": "0",
"height": "0",
"type": "1",
"distance_time": "26 days ago",
"avatar": "uploads/MemberImage/20200922-1436-image-5f699b536f438-0.png",
"position": 2
},
{
"content": "I am fine, thanks",
"detail_id": "2",
"time": "17:57:45",
"chat_time": "2020-09-24 17:57:45",
"width": "0",
"height": "0",
"type": "1",
"distance_time": "26 days ago",
"avatar": "uploads/MemberImage/20200922-1436-image-5f699b536f438-0.png",
"position": 2
},
],
"2020-09-24": [
{
"content": "how are you",
"detail_id": "1",
"time": "17:57:28",
"chat_time": "2020-09-24 17:57:28",
"width": "0",
"height": "0",
"type": "1",
"distance_time": "26 days ago",
"avatar": "uploads/MemberImage/20200922-1436-image-5f699b536f438-0.png",
"position": 2
},
{
"content": "I am fine, thanks",
"detail_id": "2",
"time": "17:57:45",
"chat_time": "2020-09-24 17:57:45",
"width": "0",
"height": "0",
"type": "1",
"distance_time": "26 days ago",
"avatar": "uploads/MemberImage/20200922-1436-image-5f699b536f438-0.png",
"position": 2
},
],
);
sort($room_details);
// result
// array sort php
$room_details = array(
"2020-09-24": [
...
],
"2020-09-27": [
...
],
);
php sort
PHP function sort(array &$array, int $flags) bool
---------------------------------------------
Sort an array
Parameters:
array--$array--The input array.
int--$flags--[optional] The optional second parameter sort_flags may be used to modify the sorting behavior using these values.
Sorting type flags: SORT_REGULAR - compare items normally (don't change types).
Returns: true on success or false on failure.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us