/**
* Sorts an object into an order
*
* @require jQuery
*
* @param object Our JSON object to sort
* @param type Only alphabetical at the moment
* @param identifier The array or object key to sort by
* @param order Ascending or Descending
*
* @returns Array
*/function sortItems(object, type, identifier, order){var returnedArray =[];var emptiesArray =[];// An array for all of our empty cans// Convert the given object to an array
$.each(object,function(key,object){// Store all of our empty cans in their own array// Store all other objects in our returned arrayobject[identifier]==null? emptiesArray.push(object): returnedArray.push(object);});// Sort the array based on the type givenswitch(type){case'alphabetical':
returnedArray.sort(function(a, b){return(a[identifier]== b[identifier])?0:(// Sort ascending or descending based on order given
order =='asc'? a[identifier]> b[identifier]: a[identifier]< b[identifier])?1:-1;});break;default:}// Return our sorted array along with the empties at the bottom depending on sort orderreturn order =='asc'? returnedArray.concat(emptiesArray): emptiesArray.concat(returnedArray);}