general-functions.pl: Remove unused srtarray function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2024-03-23 15:52:17 +01:00
parent 11e75894ce
commit 9c9f637e16

View File

@@ -892,87 +892,6 @@ sub findhasharraykey {
}
}
sub srtarray
# Darren Critchley - darrenc@telus.net - (c) 2003
# &srtarray(SortOrder, AlphaNumeric, SortDirection, ArrayToBeSorted)
# This subroutine will take the following parameters:
# ColumnNumber = the column which you want to sort on, starts at 1
# AlphaNumberic = a or n (lowercase) defines whether the sort should be alpha or numberic
# SortDirection = asc or dsc (lowercase) Ascending or Descending sort
# ArrayToBeSorted = the array that wants sorting
#
# Returns an array that is sorted to your specs
#
# If SortOrder is greater than the elements in array, then it defaults to the first element
#
{
my ($colno, $alpnum, $srtdir, @tobesorted) = @_;
my @tmparray;
my @srtedarray;
my $line;
my $newline;
my $ctr;
my $ttlitems = scalar @tobesorted; # want to know the number of rows in the passed array
if ($ttlitems < 1){ # if no items, don't waste our time lets leave
return (@tobesorted);
}
my @tmp = split(/\,/,$tobesorted[0]);
$ttlitems = scalar @tmp; # this should be the number of elements in each row of the passed in array
# Darren Critchley - validate parameters
if ($colno > $ttlitems){$colno = '1';}
$colno--; # remove one from colno to deal with arrays starting at 0
if($colno < 0){$colno = '0';}
if ($alpnum ne '') { $alpnum = lc($alpnum); } else { $alpnum = 'a'; }
if ($srtdir ne '') { $srtdir = lc($srtdir); } else { $srtdir = 'src'; }
foreach $line (@tobesorted)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
# Darren Critchley - juggle the fields so that the one we want to sort on is first
my $tmpholder = $temp[0];
$temp[0] = $temp[$colno];
$temp[$colno] = $tmpholder;
$newline = "";
for ($ctr=0; $ctr < $ttlitems ; $ctr++) {
$newline=$newline . $temp[$ctr] . ",";
}
chop($newline);
push(@tmparray,$newline);
}
}
if ($alpnum eq 'n') {
@tmparray = sort {$a <=> $b} @tmparray;
} else {
@tmparray = (sort @tmparray);
}
foreach $line (@tmparray)
{
chomp($line);
if ($line ne '') {
my @temp = split(/\,/,$line);
my $tmpholder = $temp[0];
$temp[0] = $temp[$colno];
$temp[$colno] = $tmpholder;
$newline = "";
for ($ctr=0; $ctr < $ttlitems ; $ctr++){
$newline=$newline . $temp[$ctr] . ",";
}
chop($newline);
push(@srtedarray,$newline);
}
}
if ($srtdir eq 'dsc') {
@tmparray = reverse(@srtedarray);
return (@tmparray);
} else {
return (@srtedarray);
}
}
sub FetchPublicIp {
my %proxysettings;
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);