Question: struggling with how to write a function that sorts this array properly into two separate arrays. I can't figure out where to go from here, I know i need to probably use the sort method but I don't know how to write it properly, I've only been working with JS for a couple weeks.

```
    let mixedUpAnimals = [
     {name: 'chinchilla', soft: true},
     {name: 'armadillo', soft: false},
     {name: 'bear', soft: true},
     {name: 'porcupine', soft: false},
     {name: 'hedgehog', soft: false},
     {name: 'honey badger', soft: false},
     {name: 'mouse', soft: true}
     ]
     for(var i = 0; i < mixedUpAnimals.length; i++){
     if (mixedUpAnimals[i].soft === true);

```

Answer: 
You can do the separation in a single iteration as well, once you sorted. 

```js
let mixedUpAnimals = [
     {name: 'chinchilla', soft: true},
     {name: 'armadillo', soft: false},
     {name: 'bear', soft: true},
     {name: 'porcupine', soft: false},
     {name: 'hedgehog', soft: false},
     {name: 'honey badger', soft: false},
     {name: 'mouse', soft: true}
  ],
  sortCb = (x, y)=> x.name.localeCompare(y.name),
  separate = A => A.reduce((a, e) => ((e.soft && a.s || a.ns).push(e), a), {s: [], ns: []}),
  {s, ns} = separate(mixedUpAnimals.sort(sortCb));

  console.log('Soft: ', s);
  console.log('Non soft: ', ns);
```

Also you can avoid sort at the beginning, find the proper index in child array and place the item in child array at appropriate index, even it is a searching multiple time but remember we are searching in smaller arrays, so the entire operation, (including sort and separate) will have much less complexity and faster. here is the version:

```js
let mixedUpAnimals = [
     {name: 'chinchilla', soft: true},
     {name: 'armadillo', soft: false},
     {name: 'bear', soft: true},
     {name: 'porcupine', soft: false},
     {name: 'hedgehog', soft: false},
     {name: 'honey badger', soft: false},
     {name: 'mouse', soft: true}
  ],
  separate = A => A.reduce((a, e) => {
    let t = (e.soft && a.s || a.ns),
        idx = t.findIndex(v=> v.name.localeCompare(e.name) > 0);
    t.splice(idx < 0 ? t.length : idx, 0 , e);
    return a;
  }, {s: [], ns: []}),
  {s, ns} = separate(mixedUpAnimals);

console.log('Soft: ', s);
console.log('Non soft: ', ns);
```
```js
 let mixedUpAnimals = [
   {name: 'chinchilla', soft: true},
   {name: 'armadillo', soft: false},
   {name: 'bear', soft: true},
   {name: 'porcupine', soft: false},
   {name: 'hedgehog', soft: false},
   {name: 'honey badger', soft: false},
   {name: 'mouse', soft: true}
]

let softAnimals = [];
let notSoftAnimals =[];

mixedUpAnimals.map((item) => { 
  item.soft ? softAnimals.push(item) : notSoftAnimals.push(item)
});

function sortArrayOfObject(items){
  return items.sort((a, b)=> {
    var nameA = a.name.toUpperCase(); // ignore upper and lowercase
    var nameB = b.name.toUpperCase(); // ignore upper and lowercase
    if (nameA < nameB) return -1;
    if (nameA > nameB) return 1;
    return 0;
  });
}

console.log(sortArrayOfObject(softAnimals))
console.log(sortArrayOfObject(notSoftAnimals))
```