I have some arrays all of equal lengths and four null values are present at random positions for each those arrays and i need to sort those array of numbers, provided the position of null is not altered.
For example, My arrays:
var arr1 = [6, 3, null, 5, null, 4, null, null];
var arr2 = [null, 7, 4, null, 6, null, 5, null];
Expected output should be: (null positions are not altered)
var arr1 = [3, 4, null, 5, null, 6, null, null];
var arr2 = [null, 4, 5, null, 6, null, 7, null];
Please Help advise or suggest somecode in the below function so to acheive this requirement in javascript
function sortByNotalterNull(arr) {
//somecode here
return arr;
};
sortByNotalterNull(arr1);