Skip to content

Commit

Permalink
Merge pull request #153 from GerFr/150-sort-by-distance
Browse files Browse the repository at this point in the history
sort by magnitude
  • Loading branch information
GerFr authored Jun 10, 2024
2 parents eeff782 + 523530c commit 1c7e811
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions articles.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ <h2 class="display-3">Star Collection</h2>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Magasc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Mag', 'asc')">
<img src="assets/icons/ascc.png" class="cart-image-checkout">
<p class="lead text-muted">Magnitude</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Magdsc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Mag', 'dsc')">
<img src="assets/icons/descc.png" class="cart-image-checkout">
<p class="lead text-muted">Magnitude</p>
</a>
</div>
</div>
</div>
</div>
</nav>
Expand Down
Binary file added assets/icons/ascc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/descc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function setSort(key, direction) {
function sortData(data, key, direction) {
let newData = data;

if ((key==="Price")||(key==="Distance")){
if ((key==="Price")||(key==="Distance")||(key=="Mag")){
switch (direction) {
case "asc":
newData.sort((a, b) => a[key] - b[key]);
Expand Down

0 comments on commit 1c7e811

Please sign in to comment.