[Mariadb] 10.7.0 버전에 새로 생긴 natural_sort_key() 정보
기타 [Mariadb] 10.7.0 버전에 새로 생긴 natural_sort_key()본문
이번에 mariadb 10.7.0버전에서 네추럴 정렬관련해서 기능추가가 되었다고합니다.
사용법은 order by 절에 natural_sort_key(정렬하고자하는 컬럼)을 넣어 주시면 됩니다.
아래 해당 예시는 단순 order by와 natural_sort_key로 정렬 했을때 차이를 보여 주시는 예시입니다.
참고 링크 : https://mariadb.org/10-7-preview-feature-natural-sort/
추천
10
10
댓글 6개

고생했던 부분 풀리는거 같아 좋네요. 정보 감사합니다.

오, 이것은 귀하군요.

10,7 만세네~~

감사합니다.

오호 매우 좋은 기능이네요

참고로 PHP에서는 natsort(), natcasesort() 함수가 같은 역할을 합니다. (PHP 4, 5, 7, 8)
+ natsort()
- https://www.php.net/manual/en/function.natsort.php
- http://docs.php.net/manual/kr/function.natsort.php
+ natcasesort()
- https://www.php.net/manual/en/function.natcasesort.php
- http://docs.php.net/manual/kr/function.natcasesort.php
$temp = [
'10.1.22',
'10.2.1',
'10.2.12',
'10.3.32',
'10.7.0',
'5.5.31',
];
print_r($temp);
natsort($temp);
print_r($temp);
↓
Array
(
[0] => 10.1.22
[1] => 10.2.1
[2] => 10.2.12
[3] => 10.3.32
[4] => 10.7.0
[5] => 5.5.31
)
Array
(
[5] => 5.5.31
[0] => 10.1.22
[1] => 10.2.1
[2] => 10.2.12
[3] => 10.3.32
[4] => 10.7.0
)
+ natsort()
- https://www.php.net/manual/en/function.natsort.php
- http://docs.php.net/manual/kr/function.natsort.php
+ natcasesort()
- https://www.php.net/manual/en/function.natcasesort.php
- http://docs.php.net/manual/kr/function.natcasesort.php
$temp = [
'10.1.22',
'10.2.1',
'10.2.12',
'10.3.32',
'10.7.0',
'5.5.31',
];
print_r($temp);
natsort($temp);
print_r($temp);
↓
Array
(
[0] => 10.1.22
[1] => 10.2.1
[2] => 10.2.12
[3] => 10.3.32
[4] => 10.7.0
[5] => 5.5.31
)
Array
(
[5] => 5.5.31
[0] => 10.1.22
[1] => 10.2.1
[2] => 10.2.12
[3] => 10.3.32
[4] => 10.7.0
)