question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible incorrect sorting in KnownHeaders.cs

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hello,

Looks like there are some incorrect sorting operations in KnownHeader.cs.

Perhaps, there should be the .OrderBy(...).ThenBy(...) invocation sequence instead of .OrderBy(...).OrderBy(...).

The first case:

....
.Concat(corsRequestHeaders)
.OrderBy(header => header)
.OrderBy(header => !requestPrimaryHeaders.Contains(header))
.Select((header, index) => new KnownHeader
....

The second case:

....
.Concat(corsResponseHeaders)
.OrderBy(header => header)
.OrderBy(header => !responsePrimaryHeaders.Contains(header))
.Select((header, index) => new KnownHeader
....

The third case:

....
.OrderBy(header => header)
.OrderBy(header => !responsePrimaryHeaders.Contains(header))
.Select((header, index) => new KnownHeader
....

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adityamandaleekacommented, Feb 25, 2022

There isn’t a bug here; OrderBy does a stable sort and the second OrderBy in these cases just checks for presence in a set, so we always end up with the same result (specifically, one where the headers are in order and the primary ones come first).

I suppose it would be slightly cleaner for us to first sort on set presence, then use ThenBy to sort by header which would accomplish the same thing.

0reactions
adityamandaleekacommented, Feb 25, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Suspicious sortings in Unity, ASP.NET Core, and more
The sequence turned out to be sorted by the secondary key. But the sorting by primary key was not saved. If you've ever...
Read more >
Suspicious sortings in Unity, ASP.NET Core, and more
The sequence turned out to be sorted by the secondary key. But the sorting by primary key was not saved. If you've ever...
Read more >
Cannot sort table headers by ascending or descending
I am using jQuery jTable and sorting is enabled by default. Is is possible to do this by using a jQuery? Here's my...
Read more >
Solved: Incorrect Sorting
Solved: Hello, Background: I am pulling data from an OData source. I find it strange that my data will no sort properly. See...
Read more >
GridView.SortExpression Property (System.Web.UI. ...
The following example demonstrates how to use the SortExpression property to determine the name of the column being sorted. ASP.NET (C#)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found