Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

sort a word "system" in perl/shell without using built in
functions

output should be emssty

Answer Posted / umesh

$value = "system";
@SortedArray = split('',$value);
$strlength = @SortedArray;
print "Current sort @SortedArray
";
$swapped = 0;
for($i=0; $i < $strlength; $i++){
for (my $j = 0; $j < $strlength-1-$i; $j++) {
if($SortedArray[$j] gt $SortedArray[$j+1]){
$tmp = $SortedArray[$j];
$SortedArray[$j] = $SortedArray[$j+1];
$SortedArray[$j+1] = $tmp;
$swapped =1;
}
}
if ($swapped) {
next;
}
}

print join('', split(' ', "@SortedArray")), "
";

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the peculiarity of returning values by subroutines in perl?

905


Which of these is a difference between Perl and C++ ?

1024


Who created perl?

911


Comment on data types and variables in perl.

917


How to create a package?

945


How to change a directory in perl?

918


What are the purpose of close(), getc() and read() functions?

873


“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?

1004


What does read () command do?

919


What is 'commit' command in perl?

1081


How to start perl in interactive mode?

1038


What are the advantages of perl programming?

990


How many loop control keywords are there in perl?

929


Explain grooving and shortening of arrays?

1083


What happens in dereferencing?

1030