How to compare a list of lists/sets in python?

So you want the difference between two lists of items. first_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘3c3c3c’, 3333]] secnd_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘8p8p8p’, 9999], [‘Test4.doc’, ‘4d4d4d’, 4444]] First I’d turn each list of lists into a list of tuples, so as tuples are hashable (lists are not) … Read more

How do I compare two dictionaries in Swift?

As already mentioned by Hot Licks you can use NSDictionary method isEqualToDictionary() to check if they are equal as follow: let dic1: [String: AnyObject] = [“key1”: 100, “key2”: 200] let dic2: [String: AnyObject] = [“key1”: 100, “key2”: 200] let dic3: [String: AnyObject] = [“key1”: 100, “key2”: 250] println( NSDictionary(dictionary: dic1).isEqualToDictionary(dic2) ) // true println( NSDictionary(dictionary: … Read more

Compare two dates in Java

Date equality depends on the two dates being equal to the millisecond. Creating a new Date object using new Date() will never equal a date created in the past. Joda Time’s APIs simplify working with dates; however, using the Java’s SDK alone: if (removeTime(questionDate).equals(removeTime(today)) … public Date removeTime(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); … Read more

Java. Ignore accents when comparing strings

I think you should be using the Collator class. It allows you to set a strength and locale and it will compare characters appropriately. From the Java 1.6 API: You can set a Collator’s strength property to determine the level of difference considered significant in comparisons. Four strengths are provided: PRIMARY, SECONDARY, TERTIARY, and IDENTICAL. … Read more

Compare 2 images in php

Most of the other answers refer to using various hashing functions. The question explicitly is asking about comparing the contents of the images, not about comparing the files. This means you end up having to actually understand the contents of the image. In PHP there are two extensions often used for this, ImageMagick and GD. … Read more