Adding generic data functions and table sorting
Using functions now in aila2.js rather than keeping copy here.