//import ItemFilter from './ItemFilter.js';
import ItemListing from './ItemListing.js';

function cmp_fn(a,b){
  var A = (a.model+a.color).toUpperCase(); // ignore upper and lowercase
  var B = (b.model+b.color).toUpperCase(); // ignore upper and lowercase
  if (A < B) {
    return -1;
    }
  else if (A > B) {
    return 1;
    }
  else{ // names must be equal
    return 0;
    }
  }

function ItemBrowser(initialVnode) {
  return {
    view: function(vnode) {
      var items = vnode.attrs.items
      items.sort(cmp_fn);
      return m(".item-browser.container", [
        //m(ItemFilter),
        m(ItemListing, {items: items})
        ]);
    }
  }
}
export default ItemBrowser