merge two array in ascending order code example
Example 1: sort array of objects in ascending order in js
homes.sort(function(a, b) {
return parseFloat(a.price) - parseFloat(b.price);
});
Example 2: sort odd and even ascending order numbers in separate lists
sort odd and even ascending numbers into seperate lists
numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
def isEven(n) :
return ((n % 2) == 0)
oddnumbers = []
evennumbers = []
for i in numbers:
if isEven(i) == True:
evennumbers.append(i)
else:
oddnumbers.append(i)
print(oddnumbers)
print(evennumbers)