loading

I was playing around with batch and came up with this, its a program that will ask for three numbers then sort them from the smallest to the biggest. If anyone has a better way of doing this please comment below because I would love to see a simpler version.

Step 1: The Code

@echo off
title Number Order
:main
cls
set /p input1=First number:
set /p input2=Second number:
set /p input3=Third number:
if %input1% LSS %input2% (
if %input1% LSS %input3% (
set num1=%input1%
) ELSE (
set num1=%input3%
)
if %input2% LSS %input3% (
set num2=%input2%
set num3=%input3%
) ELSE (
set num2=%input3%
set num3=%input2%
)
)
if %input2% LSS %input3% (
if %input2% LSS %input1% (
set num1=%input2%
) ELSE (
set num1=%input1%
)
if %input3% LSS %input1% (
set num2=%input3%
set num3=%input1%
) ELSE (
set num2=%input1%
set num3=%input3%
)
)
if %input3% LSS %input1% (
if %input3% LSS %input2% (
set num1=%input3%
) ELSE (
set num1=%input2%
)
if %input1% LSS %input2% (
set num2=%input1%
set num3=%input2%
) ELSE (
set num2=%input2%
set num3=%input1%
)
)
cls
echo %num1%
echo %num2%
echo %num3%
pause
goto main

<p>There are a lot of pages showing sort algorythms working. You can search them with Google. Some are awesomely fast.</p>
<p>Sorry if there are any bugs in the code, it hasn't been fully tested. But it should work fine with most combinations of numbers.</p>

About This Instructable

322views

2favorites

License:

More by Gwalin:Batch Game: Dodgems Batch Game: Slide Puzzle Batch Number Organiser 
Add instructable to: