Skip to content

Commit

Permalink
stb_rect_pack: make rect_height_compare a stable sort
Browse files Browse the repository at this point in the history
This was written by Joshua Simmons <[email protected]>
nothings/stb#1299
  • Loading branch information
slouken committed Oct 1, 2024
1 parent 31081f5 commit 54a63aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stb_rect_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
// Bugfixes / warning fixes
// Jeremy Jaussaud
// Fabian Giesen
// Joshua Simmons
//
// Version history:
//
Expand Down Expand Up @@ -534,7 +535,11 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
return -1;
if (p->h < q->h)
return 1;
return (p->w > q->w) ? -1 : (p->w < q->w);
if (p->w > q->w)
return -1;
if (p->w < q->w)
return 1;
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
}

static int STBRP__CDECL rect_original_order(const void *a, const void *b)
Expand Down

0 comments on commit 54a63aa

Please sign in to comment.