Question: Suppose i have a 2D numpy array. Given n, i wish to nulify all elements in the matrix except the top n.

I've tried `idx = (-y_pred).argsort(axis=-1)[:, :n]` to determine what are the indices of the largest n values, but `idx` shape is [H,W,n], and i don't understand why.

I've tried -

```
sorted_list = sorted(y_pred, key=lambda x: x[0], reverse=True)
top_ten = sorted_list[:10]

```

But it didn't really return top 10 indices.

Is there an efficient way to find top n indices and zero the rest?

**EDIT**
input is a NxM matrix of values, and output is the same matrix of size NxM, such that all values are 0 except in indices that correspond to top 10 values

Answer: 
I found a solution. Delete align-items on css code and the overflow problem disappears. To center the image just use margin: auto. 

New code : <https://jsfiddle.net/k1fmodv5/>

CSS

```
html,body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: auto;
  font-family: 'Libre Baskerville', serif;
}

body {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
  grid-gap: 10px 10px;
}

header {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(2, 1fr);
  grid-row: 1/ 3;
  grid-column: 1/ 13;
  grid-gap: 10px 10px;
  background-color: grey;
}

.type {
  display: grid;
  grid-row: 1/ 2;
  grid-column: 1/ 8;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  align-self: center;
  background-color: lightcoral;
  min-height: 0;
}

.nav {
  display: grid;
  grid-row: 2/ 3;
  grid-column: 1/ 8;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: 1fr;
  align-self: center;
  background-color: crimson;
}

a {
   color: black;
   text-decoration: none;
   padding: 10px;
 }

img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.content {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
  grid-column: 1/ 13;
  grid-row: 3 / 13;
  grid-gap: 10px 10px;
 }

 .library {
   grid-column: 4/ 10;
   grid-row: 4 / 10;
   margin:auto;
 }

```

Thank you all for your help !
I try to make this view as simple as I can

This is a link of jsfiddle, have a look: <https://jsfiddle.net/dupinderdhiman/zum2kxpw/5/>

```css
a{
  padding: 10px;
  border-top: 1px solid blue;
  border-bottom: 1px solid blue;
}

img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}
```

```html
<!-- 
  Bootstrap docs: https://getbootstrap.com/docs
-->

<div class="container">
  <div class="row">
    <div class="col-12">
     <h1>Title</h1> 
    </div>
    <div class="col-12">
       <div class="nav">
        <a href="#"> x </a>
        <a href="#"> x </a>
        <a href="#"> x </a>
        <a href="#"> x </a>
        <a href="#"> x </a>
        <a href="#"> x </a>
      </div>
    </div>
  </div>
  <div class="row">
  <div class='col-12 mt-1'>
    <img src="https://i.pinimg.com/originals/2d/8f/3e/2d8f3ef4a6bac30d0a4c7a44f7b3d574.jpg" alt="">
  </div>
  </div>  
</div>
```