---
title: "Discussion on \"JavaScript Array Methods - Sorting Items\" | Hashnode"
description: "Discussion on \"JavaScript Array Methods - Sorting Items\". To randomly sort items in an array using sort(), call the method on the array and pass in a compare function that returns both negative and positive values."
url: "https://hashnode.com/posts/javascript-array-methods-sorting-items/64117b2723ae346d76041292"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript Array Methods - Sorting Items](https://maame.hashnode.dev/javascript-array-methods-sorting-items?utm_source=hashnode&utm_medium=feed)

To randomly sort items in an array using sort(), call the method on the array and pass in a compare function that returns both negative and positive values.

Mar 15, 2023 · 4 min read · maame.hashnode.dev  
Read the article

-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#array-methods](https://hashnode.com/tag/array-methods)
-   [#javascript-array-methods](https://hashnode.com/tag/javascript-array-methods)

## Written by

[Maame Yaa Serwaa Bona-Mensa](https://hashnode.com/@maame)

@maame

  
[View profile](https://hashnode.com/@maame)

On a journey to becoming a Frontend Engineer and a better human!

I am a Frontend Engineer and a Creative Developer. I love learning and sharing my journey to inspire others.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
