<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
var $num = $(".p"),
btn = $(".btn"),
inp = $("input");
btn.on({
"click": sort
});
function sort() {
var val = $.map($num, function(el) {
return +el.textContent
}).sort(function(a, b) {
return a - b
});
inp.val(val)
}
});
</script>
</head>
<body>
<input type="text">
<div class="p">10</div>
<div class="p">0</div>
<div class="p">5</div>
<div class="p">-1</div>
<button class="btn">Sort</button>
<script>
</script>
</body>
</html>