Batch Number Organiser

338

2

2

Posted

Introduction: Batch Number Organiser

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

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Space Challenge

      Space Challenge
    • Trash to Treasure

      Trash to Treasure
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

    There are a lot of pages showing sort algorythms working. You can search them with Google. Some are awesomely fast.

    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.