How to sort versioning info

前端 未结 3 1311
误落风尘
误落风尘 2020-12-30 01:39

What\'s the right way, to handle versioning indicators like 2.4 or 2.4.0.9 etc. to get the ability of sorting versions.

PHP says, that

3条回答
  •  时光说笑
    2020-12-30 01:52

    Or, just use natsort:

    $array = array('2.4','2.16.6','2.3.4','2.4.0.9');
    natsort($array);
    print_r($array);
    
    #Array ( [2] => 2.3.4 [0] => 2.4 [3] => 2.4.0.9 [1] => 2.16.6 )
    

提交回复
热议问题