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 does -> symbol indicates in Perl?

975


What are the various perl data types based on the context?

939


Explain the default scope of variables in perl?

945


You want to open and read data files with perl. How would you do that?

882


Explain the meaning of closure in perl.

1031


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

1052


Explain the use of 'my' keyword in perl?

1022


How many data types are there in perl?

964


What happens in dereferencing?

1043


How to open a directory in perl?

1111


What package you use to create a windows services?

887


Can you add two arrays together?

924


How can I display all array element in which each element will display on next line in perl ?

932


Give an example of using the -n and -p option.

1001


Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

972