function sort(){
var x=parseInt(document.getElementById("num1").value);
var y=parseInt(document.getElementById("num2").value);
var z=parseInt(document.getElementById("num3").value);
if(x>y && x>z){
if(y>z){
alert(x+","+y+","+z);
}
else
{
alert(x+","+z+","+y)
}
}
else if(y>x && y>z) {
if(x>z){
alert(y+","+x+","+z);
}
else{
alert(y+","+z+","+x);
}
}
else if(z>x && z>y){
if(x>y){
alert(z+","+x+","+y);
}
else{
alert(z+","+y+","+x);
}
}
}
<input type="text" id="num1" name="">
<input type="text" id="num2" name="">
<input type="text" id="num3" name="">
<button type="submit" onclick="sort()">Sort</button>
Hello Everyone, Can I ask there's another way to sort 3 numbers? Because the code is too long how to make it short or a better way to create this sort of numbers. Sorry Beginner here :).