Questions tagged [icomparer]

IComparer is an interface provided by the .NET framework, used in conjunction with the Array.Sort and Array.BinarySearch methods. It provides a way to customize the sort order of a collection. It contains a single Compare method that compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. There is also a generic version of this interface. Supported in .NET 4, 3.5, 3.0, 2.0, 1.1, 1.0. Source: MSDN

228 questions
0
votes
1 answer

icomparer on multiple lists

I have 3 different lists with the same items in it. ( List ) When I use an icomparer to sort them on date, my c# form sorts them in each list en doesn't take itemsall together and sort it after that. private List lijstPublicBlogs; …
Swag
  • 2,090
  • 9
  • 33
  • 63
0
votes
1 answer

Using IntPtr with IComparer

Three related questions here: The IntPtr structure apparently does not implement < and > operators. Is there a way to perform this comparison without converting the structure to an int or long? Why are the < and > operators not implemented on this…
Raheel Khan
  • 14,205
  • 13
  • 80
  • 168
0
votes
1 answer

Using OrderBy with custom IComparer with SubSonic

I am trying to call OrderBy() using a custom IComparer on a SubSonic IQueryable like so: IQueryable sortedFoos = FooObject.All() .OrderBy(f => f, new FooObjectComparer()); However when I then try to enumerate over sortedFoos or…
Annabelle
  • 10,596
  • 5
  • 27
  • 26
0
votes
3 answers

Linq compared to IComparer

I have seen this class that looks like this: /// /// Provides an internal structure to sort the query parameter /// protected class QueryParameter { public QueryParameter(string name, string value) …
r3plica
  • 13,017
  • 23
  • 128
  • 290
0
votes
3 answers

How to implement IComparer in C# for an interface

I have an interface named IEmployee. I need to implement the IComparer to the implementation of my interface. Here is my code, interface IEmployee { String Name {get;set;} DateTime DOB {get;set;} } I have created a child class for…
Thorin Oakenshield
  • 14,232
  • 33
  • 106
  • 146
0
votes
2 answers

List of all uncommon elements in arraylist

I have 2 ArrayList, which contains the filenames, now one list has more names and other might have less, or sometime equal, i want to list the filenames which are not common in both arraylist and accordingly update the database, i was able to check…
Abbas
  • 4,948
  • 31
  • 95
  • 161
0
votes
1 answer

Custom IComparer

I'm wanting to create a IComparer for a SortedDictionary that will sort everything alphabetically but if it see a key of 'Other' it will put 'Other' at the end of the list.
vdh_ant
  • 12,720
  • 13
  • 66
  • 86
0
votes
3 answers

How can I use an IComparer to sort by arbitrary values?

I receive a sorted list of integers which I would like to use to sort a ListCollectionView via ListCollectionView.CustomSort. This property accepts an IComparer and I've created one but, as expected, I can only compare values on generic objects x…
erodewald
  • 1,815
  • 20
  • 45
0
votes
2 answers

How can I change the sort order using an IComparer in .NET

I'm sure this is simple but it has me stumped. I want, simplified, to sort my alphabet but putting Ds between As and Bs. I think I want a custom IComparer to do this. How would I finish this IComparer implementation to pass my Assertion? The…
GaryB96
  • 371
  • 5
  • 13
0
votes
2 answers

How to specify an IComparer for a particular property on a model that can be used for Silverlight DataGrid column sorting

I have a Silverlight datagrid with a column who's binding is set to a string property on the model. These strings are alphanumeric, so I have created a custom IComparer to sort them appropriately. My question is how can I force the grid to use this…
spoof3r
  • 607
  • 8
  • 23
0
votes
1 answer

IComparer, OrderBy and Linq

I have a custom comparer I want to use with OrderBy. This comparer enables to sort nested lists the way I want. I perfectly works somewhere else, but I can't make it work the way I want with Linq. Can you tell me where I'm wrong? EDIT : the way I…
Sheamus
  • 223
  • 1
  • 5
  • 15
0
votes
5 answers

IComparer sorting by different criterias

I have a ListView and I am trying to sort them where items with a BackColor of red would be first, and then items with a ForeColor of red, and lastly the rest of the items, but all of them should be sorted by name within their group. I wrote this…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
0
votes
1 answer

Possible issue with IComparer and SortedDictionary

I am trying to create a SortedDictionary where its key is a string that represents a File/Folder path. I am trying to sort that dictionary based on path depths. My criteria just checks for the number of slashes in each path and puts the path with…
Zaid Amir
  • 4,727
  • 6
  • 52
  • 101
0
votes
2 answers

Sorting Windows.Forms.ListView by second column

I want to sort ListView items by the content of second column (which can be either "Online" or "Offline"). Sorting will be done only in one specific place in code, so the solution doesn't have to be flexible. More than that, it should be easy to…
Xirdus
  • 2,997
  • 6
  • 28
  • 36
0
votes
1 answer

Implementing iComparer for custom objects after converting a Dictionary to SortedDictionary

I'm having trouble implementing an IComparer method. Essentially, I want to compare the properties of two custom objects (the properties are of type integer). dE is a Dictionary(Of String, customObj) prTabIndex is a property of customObj and is of…
sacredfaith
  • 850
  • 1
  • 8
  • 22