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.

Is there any way to ignore array order when diffing?

See original GitHub issue

Say I create a diff for these 2 arrays

var a1 = @"
{
    "items": [
        "one",
        "two"
}";

var a2 = @"
{
    "items": [
        "two",
        "one"
}";

Is there some way of causing the diff to recognise them as the same array, since they only differ in the items’ order?

I am using Simple mode for Array diffing

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

2reactions
goldeneye977commented, Feb 19, 2022

+1

2reactions
MaorDavidzoncommented, Feb 1, 2022

+1 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expect Arrays to be equal ignoring order
The object portion of this answer will not actually verify that the objects match, since it is only comparing the mapped arrays. You...
Read more >
Diff JSON comparision by ignoring the order.
JSON diffs require array elements to be in the same order, which is why you are seeing this behavior. One way to do...
Read more >
array_diff - Manual
array_diff provides a handy way of deleting array elements by their value, without having to unset it by key, through a lengthy foreach...
Read more >
How do I compare two arrays in JavaScript?
Comparing two arrays in JavaScript using either the loose or strict equality operators ( == or === ) will most often result in...
Read more >
Array.prototype.sort() - JavaScript - MDN Web Docs
The sort () method of Array instances sorts the elements of an array in place and returns the reference to the same array,...
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