Comparing 2 lists consisting of dictionaries with unique keys in python

Assuming that the dicts line up like in your example input, you can use the zip() function to get a list of associated pairs of dicts, then you can use any() to check if there is a difference: >>> list_1 = [{‘unique_id’:’001′, ‘key1′:’AAA’, ‘key2′:’BBB’, ‘key3′:’EEE’}, {‘unique_id’:’002′, ‘key1′:’AAA’, ‘key2′:’CCC’, ‘key3′:’FFF’}] >>> list_2 = [{‘unique_id’:’001′, ‘key1′:’AAA’, ‘key2′:’DDD’, … Read more

How to compare two dataframe and print columns that are different in scala

From the scenario that is described in the above question, it looks like that difference has to be found between columns and not rows. So, to do that we need to apply selective difference here, which will provide us the columns that have different values, along with the values. Now, to apply selective difference we … Read more

Sort an array in the same order of another array

Use indexOf() to get the position of each element in the reference array, and use that in your comparison function. var reference_array = [“ryan”, “corbin”, “dan”, “steven”, “bob”]; var array = [“bob”, “dan”, “steven”, “corbin”]; array.sort(function(a, b) { return reference_array.indexOf(a) – reference_array.indexOf(b); }); console.log(array); // [“corbin”, “dan”, “steven”, “bob”] Searching the reference array every time … Read more