# Batch Number Organiser

409

2

2

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.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## 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

## Recommendations

• ### Internet of Things Class

22,818 Enrolled

## 2 Discussions

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.