mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
99_Utils.pm: sortTopicNum from DS_Starter (Forum #98578)
git-svn-id: https://svn.fhem.de/fhem/trunk@18913 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e455a4edf2
commit
66742cab68
@ -244,6 +244,27 @@ round($$)
|
||||
return sprintf("%.${n}f",$v);
|
||||
}
|
||||
|
||||
sub
|
||||
sortTopicNum(@)
|
||||
{
|
||||
my ($sseq,@nums) = @_;
|
||||
|
||||
my @sorted = map {$_->[0]}
|
||||
sort {$a->[1] cmp $b->[1]}
|
||||
map {[$_, pack "C*", split /\./]} @nums;
|
||||
|
||||
@sorted = map {join ".", unpack "C*", $_}
|
||||
sort
|
||||
map {pack "C*", split /\./} @nums;
|
||||
|
||||
if($sseq eq "desc") {
|
||||
@sorted = reverse @sorted;
|
||||
}
|
||||
|
||||
return @sorted;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
@ -332,6 +353,11 @@ round($$)
|
||||
value yet for this key.
|
||||
</li></br>
|
||||
|
||||
<li><b>sortTopicNum("asc"|"desc",<list of numbers>)</b><br>
|
||||
sort an array of numbers like x.x.x<br>
|
||||
(Forum #98578)
|
||||
</li></br>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
=end html
|
||||
|
Loading…
x
Reference in New Issue
Block a user