Write a program to sort integers in ascending order. Input is passed in TCL file argument.
Question
Write a program to sort integers in ascending order.
Input is passed in TCL file argument.
Solution
Sure, here is a simple TCL program that sorts integers in ascending order. The integers are passed as command line arguments.
# Get the arguments
set numbers $argv
# Sort the numbers
set sorted_numbers [lsort -integer $numbers]
# Print the sorted numbers
puts $sorted_numbers
Here's how you can run this program:
- Save the above code in a file, let's say
sort.tcl
. - Run the program with the numbers you want to sort as arguments. For example:
tclsh sort.tcl 5 3 9 1 6
This will output: 1 3 5 6 9
, which are the input numbers sorted in ascending order.
Similar Questions
Write a TCL program to get the numbers in the range (given in arguments) which are only divisible by 3 and 7.
Write a class to sort the given set of integers in descending order. Include a try block tolocate the array index out of bounds exception and catch it.
Sort the given list of numbers in ascending order. Demonstrate the first pass/sweep sort algorithm. 43 18 9 76 89 1
The task of arranging data in order is calledA OrderingB SearchingC SortingD Ascending
You have 3 numbers as user input. WAP in Java to output their values in descending order.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.