# project_panel: Make natural sort ordering consistent with other apps \(\#41080\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/fd837b348f3f96eadde3939c1267811f189d2ca2)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: fd837b348f3f96eadde3939c1267811f189d2ca2

Requested commit: fd837b348f3f96eadde3939c1267811f189d2ca2

Commit: fd837b348f3f96eadde3939c1267811f189d2ca2

Tree: 730cc1a1d62bcca0f705bf09da908466690736de

Author: Lucas Parry

Committer: GitHub

## Message

```
project_panel: Make natural sort ordering consistent with other apps (#41080)

The existing sorting approach when faced with `Dir1`, `dir2`, `Dir3`,
would only get as far as comparing the stems without numbers (`dir` and
`Dir`), and then the lowercase-first tie breaker in that function would
determine that `dir2` should come first, resulting in an undesirable
order of `dir2`, `Dir1`, `Dir3`.

This patch defers tie-breaking until it's determined that there's no
other difference in the strings outside of case to order on, at which
point we tie-break to provide a stable sort.

Natural number sorting is still preserved, and mixing different cases
alphabetically (as opposed to all lowercase alpha, followed by all
uppercase alpha) is preserved.

Closes #41080


Release Notes:

- Fixed: ProjectPanel sorting bug

Screenshots:

Before | After
----|---
<img width="237" height="325" alt="image"
src="https://github.com/user-attachments/assets/6e92e8c0-2172-4a8f-a058-484749da047b"
/> | <img width="239" height="325" alt="image"
src="https://github.com/user-attachments/assets/874ad29f-7238-4bfc-b89b-fd64f9b8889a"
/>

I'm having trouble reasoning through what was previously going wrong
with `docs` in the before screenshot, but it also seems to now appear
alphabetically where you'd expect it with this patch

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

- [6b239c3a9a496bf622e801a3a4a3a77f73add2c1](https://git.cafe/gitcafe/zed/commit/6b239c3a9a496bf622e801a3a4a3a77f73add2c1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/fd837b348f3f96eadde3939c1267811f189d2ca2?format=markdown)
