Dynamic comparator or 2 separate comparators?

Advertisements I’m working on a solution including 2 types of sorting based on a property. What do you think which one is a better approach? public class ABComparator implements Comparator<O> { private final Property property; public ABComparator(Request request) { property = getProperty(); } @Override public int compare(O o1, O o2) { if (property.someLogic()) { //… Read More Dynamic comparator or 2 separate comparators?

How to properly find the matching character in another string

Advertisements i would like to know the best way to compare a single character of a string to another whole string and find the matching character so to say. The probably most important snippets of my code are the user input request: string text = get_string("text: "); and my predefined "comparison"-string= char lowerabc[] = "abcdefghijklmnopqrstuvwxyz";… Read More How to properly find the matching character in another string

Want get value of other list where value matched

Advertisements I have two lists which are following. characteristic = [‘length’, ‘width’, ‘height’, ‘Thread length’, ‘space’] value = [‘length 34′,’width ab23′,’Thread length 8ah’,’space’,’height 099′] I have written a loop. temp_str = {} for x in characteristic: for z in value: if x in z: temp_str = z.replace(x,”) temp_str += ‘,’ print(temp_str) I am getting output:… Read More Want get value of other list where value matched