Skip to content

Instantly share code, notes, and snippets.

@briangonzalez
Created June 20, 2017 20:31
Show Gist options
  • Save briangonzalez/bc5afbb6651d2d55c3352e4900d2cda0 to your computer and use it in GitHub Desktop.
Save briangonzalez/bc5afbb6651d2d55c3352e4900d2cda0 to your computer and use it in GitHub Desktop.

Revisions

  1. briangonzalez created this gist Jun 20, 2017.
    29 changes: 29 additions & 0 deletions sorting.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    //
    // A user has purchased products from Dollar Shave Club,
    // noted below in the `purchased` array. When these products
    // came out of our database, they were unsorted.
    //
    // Write the method below, `sortProducts`, to obtain a sorted
    // array of the items purchased.
    //

    const sortedReference = [
    'ITEM-1',
    'ITEM-2',
    'ITEM-3',
    'ITEM-4',
    'ITEM-5',
    'ITEM-6',
    'ITEM-7',
    'ITEM-8',
    'ITEM-9',
    'ITEM-10',
    ];

    const purchased = [
    'ITEM-3',
    'ITEM-1',
    'ITEM-5',
    'ITEM-10',
    'ITEM-8',
    ];