custom-compare

How to ignore “-” and “.” characters in a value during sort comparison?

牧云@^-^@ 提交于 2019-12-24 07:27:53
问题 I have an html page that has a field that can be sorted. I also have created a javascript function that can sort that field in order. Let's imagine p_cSort is the 'id' name of that field. function change_sort(neworder) { document.sortForm.p_cSort.value = neworder; document.sortForm.submit(); However when I have values like 12.34 12-35 12.36 12-33 and I search for them on my search page. The results returned are 12.34 12.36 12-33 12-35 How can I ignore the characters "." and "-" when sorting?

How to ignore “-” and “.” characters in a value during sort comparison?

独自空忆成欢 提交于 2019-12-24 07:27:22
问题 I have an html page that has a field that can be sorted. I also have created a javascript function that can sort that field in order. Let's imagine p_cSort is the 'id' name of that field. function change_sort(neworder) { document.sortForm.p_cSort.value = neworder; document.sortForm.submit(); However when I have values like 12.34 12-35 12.36 12-33 and I search for them on my search page. The results returned are 12.34 12.36 12-33 12-35 How can I ignore the characters "." and "-" when sorting?

How to provide custom comparator for `std::multiset` without overloading `operator()`, `std::less`, `std::greater`?

此生再无相见时 提交于 2019-12-23 21:27:55
问题 I want a custom comparator for the following code. However, I am not allowed to overload operator() , std::less , std::greater . I tried to achieve this using lambda but gcc won't allow me to use auto as a non-static member. Any other way to make this work? #include <iostream> #include <map> #include <set> class Test { public: // bool operator () (const int lhs, const int rhs) { // not allowed // return lhs > rhs; // }; using list = std::multiset<int /*, Test*/>; std::map<const char*, list>

LinQ distinct with custom comparer leaves duplicates

泄露秘密 提交于 2019-12-18 21:26:12
问题 I've got the following classes: public class SupplierCategory : IEquatable<SupplierCategory> { public string Name { get; set; } public string Parent { get; set; } #region IEquatable<SupplierCategory> Members public bool Equals(SupplierCategory other) { return this.Name == other.Name && this.Parent == other.Parent; } #endregion } public class CategoryPathComparer : IEqualityComparer<List<SupplierCategory>> { #region IEqualityComparer<List<SupplierCategory>> Members public bool Equals(List

iPhone contacts app styled indexed table view implementation

青春壹個敷衍的年華 提交于 2019-12-04 14:51:43
问题 My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display

iPhone contacts app styled indexed table view implementation

点点圈 提交于 2019-12-03 09:15:38
My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display the sorted indexed table view. Issues accomplishing my requirement: 1. First up, I couldn't get the

LinQ distinct with custom comparer leaves duplicates

自闭症网瘾萝莉.ら 提交于 2019-11-30 19:04:54
I've got the following classes: public class SupplierCategory : IEquatable<SupplierCategory> { public string Name { get; set; } public string Parent { get; set; } #region IEquatable<SupplierCategory> Members public bool Equals(SupplierCategory other) { return this.Name == other.Name && this.Parent == other.Parent; } #endregion } public class CategoryPathComparer : IEqualityComparer<List<SupplierCategory>> { #region IEqualityComparer<List<SupplierCategory>> Members public bool Equals(List<SupplierCategory> x, List<SupplierCategory> y) { return x.SequenceEqual(y); } public int GetHashCode(List