Answers for "sort by key"

PHP
10

php sort array by key

$weight = [
    'Pete' => 75, 
    'Benjamin' => 89,
    'Jonathan' => 101
  ];  	
  ksort($weight);
Posted by: Guest on December-04-2019
0

sort dictionary by key

dictionary_items = a_dictionary.items()
sorted_items = sorted(dictionary_items)
Posted by: Guest on June-08-2020

Browse Popular Code Answers by Language