I read in a list that has 28 elements that look like this: 28.6 ft2. The list is read in not in numerical order, a bunch for different area floats. I then click on a filter on the page and it sorts the elements from least to greatest. I have an array thats preloaded with the data designed so when I do my first expect it matches exactly. I need to take the preloaded floatarray and sort them from least to greatest. Here is what I have for code:
var areaArray = ['5,089.8 ft2', '2,511.5 ft2', '15,076.8 ft2', '5,019.8 ft2', '471.4 ft2', '462.9 ft2', '5,149.3 ft2', '1,753.6 ft2', '6,520.5 ft2', '3,327.4 ft2', '3,192.9 ft2', '2,678.5 ft2',
'2,793.6 ft2', '1,195.0 ft2', '148.5 ft2', '39,077.1 ft2', '5,007.7 ft2', '1,746.4 ft2', '1,247.7 ft2', '230.0 ft2', '345.8 ft2', '114.1 ft2', '229.8 ft2', '349.3 ft2', '116.3 ft2',
'235.2 ft2', '119.5 ft2', '3,038.3 ft2'
];
//the area element list
var area = element.all(by.css("[data-bind='html: area']"));
//this has been shortened per request
}).then(function() {
browser.driver.get('http://iplan-qa.meetingmatrix.com/Apps/CapacityChart/mmidemo/auto/auto');
browser.driver.sleep(2000);
//clicks the area filter button
element.all(by.css("[data-bind='text: displayName, visible: displayName']")).get(3).click().click();
browser.driver.sleep(3000);
area.count().then(function(count) {
console.log(count);
j = 0;
function int_arr(a, b) {
return parseFloat(a) - parseFloat(b);
}
areaArray = areaArray.sort(int_arr);
areaArray = areaArray.reverse();
for (var i = 0; i < count; i++) {
//scrolls down the list element by element
browser.executeScript("arguments[0].scrollIntoView();", area.get(i).getWebElement());
area.get(i).getText().then(function(text) {
console.log(text, areaArray[j], j);
expect(text).toEqual(areaArray[j++]);
});
}
});
});
};
The results look like this:
5,089.8 ft2 5,089.8 ft2 0
2,511.5 ft2 2,511.5 ft2 1
15,076.8 ft2 15,076.8 ft2 2
5,019.8 ft2 5,019.8 ft2 3
471.4 ft2 471.4 ft2 4
462.9 ft2 462.9 ft2 5
5,149.3 ft2 5,149.3 ft2 6
1,753.6 ft2 1,753.6 ft2 7
6,520.5 ft2 6,520.5 ft2 8
//this is be shortened per request
39,077.1 ft2 1,247.7 ft2 0
15,076.8 ft2 1,746.4 ft2 1
6,520.5 ft2 1,753.6 ft2 2
5,149.3 ft2 1,195.0 ft2 3
5,089.8 ft2 2,511.5 ft2 4
5,019.8 ft2 2,678.5 ft2 5
5,007.7 ft2 2,793.6 ft2 6
3,327.4 ft2 3,038.3 ft2 7
3,192.9 ft2 3,327.4 ft2 8
areaArrayfrom smallest to biggest?