| Andrew Jeffery | 762b34a | 2024-05-23 14:53:05 +0930 | [diff] [blame] | 1 | #!/usr/bin/perl | 
|  | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later | 
|  | 3 | # | 
|  | 4 | # Copyright (C) 2013-2020 Andrey Ponomarenko's ABI Laboratory | 
|  | 5 | # Copyright (C) 2024 Code Construct | 
|  | 6 |  | 
|  | 7 | # Copied from abi-dumper | 
|  | 8 | # Written by Andrey Ponomarenko | 
|  | 9 | sub dumpSorting($) | 
|  | 10 | { | 
|  | 11 | my $Hash = $_[0]; | 
|  | 12 | return [] if(not $Hash); | 
|  | 13 | my @Keys = keys(%{$Hash}); | 
|  | 14 | return [] if($#Keys<0); | 
|  | 15 | if($Keys[0]=~/\A\d+\Z/) | 
|  | 16 | { # numbers | 
|  | 17 | return [sort {$a<=>$b} @Keys]; | 
|  | 18 | } | 
|  | 19 | else | 
|  | 20 | { # strings | 
|  | 21 | return [sort {$a cmp $b} @Keys]; | 
|  | 22 | } | 
|  | 23 | } | 
|  | 24 |  | 
|  | 25 | use Data::Dumper; | 
|  | 26 |  | 
|  | 27 | # Prevent key lengths from changing the indentation | 
|  | 28 | $Data::Dumper::Indent = 1; | 
|  | 29 | $Data::Dumper::Sortkeys = \&dumpSorting; | 
|  | 30 | $/ = undef; | 
|  | 31 | print Dumper(eval(<>)); |