Sort function used here works for any non-nested property of item's objects.
If I use a[types][type] in sort, it returns fault, "types" is not defined.
If I use a.types.type, it just returns unmodified array.
Like I said, I am horribly stuck, and any help or pointers would be greatly appreciated.