title: How do I Sort, Slice, then Map an Array?
body: <p>Im trying to sort, then <strong>slice (show last n elements of array only)</strong> and then map this array.</p>
  <p>This is the working version (react syntax) currently, with sort and map but without slicing yet.</p>
  <pre><code>{Object.keys(dataObj)
                        .sort(
                          (a, b) =&gt;
                            dataObj[a][&quot;order&quot;] -
                            dataObj[b][&quot;order&quot;]
                        )
                        .map((movie, i) =&gt; {
                          return (
                            &lt;li key={i}&gt;
                              {movie}
                              {dataObj[movie][&quot;value&quot;]}
                            &lt;/li&gt;
                          );
                        })}
  
  </code></pre>
  <p>How do I continue to slice this, in between sort and map?<br />
  This is what my pseudo code would look like.</p>
  <pre><code>{Object.keys(dataObj)
                        .sort(
                          (a, b) =&gt;
                            dataObj[a][&quot;order&quot;] -
                            dataObj[b][&quot;order&quot;]
                        )
                        .((arr)=&gt;arr.slice(arr.length-10, arr.length+1))
                        .map((movie, i) =&gt; {
                          return (
                            &lt;li key={i}&gt;
                              {movie}
                              {dataObj[movie][&quot;value&quot;]}
                            &lt;/li&gt;
                          );
                        })}
  
  </code></pre>
  <p>This obviously does not work but how do I carry on to <strong>Slice</strong> after the <strong>.sort</strong> which returns an array?<br />
  And then map this sliced array afterwards.<br />
  What syntax do I use? Thanks!</p>