---
title: "Discussion on \"What is a Comparator in JavaScript? (and why sorting algorithms depend on it)\" | Hashnode"
description: "Discussion on \"What is a Comparator in JavaScript? (and why sorting algorithms depend on it)\". Why JavaScript's default sort fails with mixed-case strings — and how a custom comparator fixes it."
url: "https://hashnode.com/posts/what-is-a-comparator-in-javascript-and-why-sorting-algorithms-depend-on-it/6a4163e4fcb3d3a44dc323a2"
---

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

Discussion

# [What is a Comparator in JavaScript? (and why sorting algorithms depend on it)](https://buggleboy.hashnode.dev/what-is-a-comparator-in-javascript-and-why-sorting-algorithms-depend-on-it?utm_source=hashnode&utm_medium=feed)

Why JavaScript's default sort fails with mixed-case strings — and how a custom comparator fixes it.

Jun 28 · 7 min read · buggleboy.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#sorting](https://hashnode.com/tag/sorting)
-   [#dsa](https://hashnode.com/tag/dsa)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#sortingtechniques](https://hashnode.com/tag/sortingtechniques)

## Written by

[Sandeep](https://hashnode.com/@buggleboy)

@buggleboy · Montreal, Canada

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

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
