sorting

Sortable table-like Java class

Does anyone know of a class in Java that has a list of elements, so that the elements are sortable by any of the elements members? The idea is basically to have some database table-like implementation, where you can just add fields to sort by. To illustrate: SomeTable table = new SomeTable(); table.addField("name", String); table.addFie...

SSRS Mircosoft Reporting: Conditional grouping

Is it possible to make a group and sort conditional? If so, is it possible to somehow do this based on the value of a textbox item? I thought I could just set the Expression of the group and sort to something like =IIF(ReportItems!TheTextBox.Value = 0, 0, Fields!FieldName.Value), which would be perfect, but it doesn't allow me to use Re...

Sorting a list based on string case

How can I sort a List by order of case e.g. smtp:[email protected] smtp:[email protected] SMTP:[email protected] I would like to sort so that the upper case record is first in the list e.g SMTP:[email protected]. ...

How to sort a subelement of XML with XSLT

I have an input XML file which I need to copy 1:1 to the output, except for one subelement which contains subitems that need to be sorted. <?xml version="1.0"?> <top> <elementA /> <elementB /> <contents> <contentitem> <id>3</id> <moretags1 /> <moretags2 /> </contentitem> <contentitem...

Sorting dictionary keys in python

I have a dict where each key references an int value. What's the best way to sort the keys into a list depending on the values? ...

Convert Collection to List

I am using TreeBidiMap from the apache collections library. I want to sort this on the values which are doubles. My method is to retrieve a Collection view of the values using Collection coll = themap.values(). Which naturally works fine. Main Question: I now want to know how I can convert/cast (not sure which is correct) coll into a Li...

Can I detect a datagrid column being sorted in Silverlight?

I need to be able to load a page of results into the grid from many tens of thousands of possible results. I want to get the data in pages of fifty from the server, using SQL Server to sort the data before returning it for binding to the datagrid. When the user sorts the dta in the datagrid by clicking a column header, I need to detect t...

Order by not working for more than 10 items

I am trying to sort a xml using linq queries using the following code Dim SortedFields = From field In feedXML.Descendants("fields") Dim sFieldList = From field In SortedFields.Descendants("field") Order By field.@position The xml is shown below, but the issue is it is ordering it in the following order 1,10,11,12,13,14...19,2,3,4,5,6...

memcmp sort

I have a single buffer, and several pointers into it. I want to sort the pointers based upon the bytes in the buffer they point at. qsort() and stl::sort() can be given custom comparision functions. For example, if the buffer was zero-terminated I could use strcmp: int my_strcmp(const void* a,const void* b) { const char* const one ...

Sorting WPF ListView with System.Linq.IGrouping<string,Class T>

Hi there, actually Im not getting problems with sorting a normal ListView.ItemsSource, my issue actually comes when I have a IGrouping List as ItemSource or SelectedItems, Im using the following snippet : private void Sort(string sortBy, ListSortDirection direction) { lastDirection = direction; ICollectionView da...

Sort algorithm to use for this specific scenario

I have two lists - let's call them details and totals. The items in details have multiple elements for each key that the list is sorted on, as such: KEY1 KEY1 KEY2 KEY2 KEY3 KEY3 KEY3 etc The items in totals will only have each key once, as such: KEY1 KEY2 KEY3 etc Both lists are sorted by key already. The lists need to be combined...

What causes a WPF ListCollectionView that uses custom sorting to re-sort its items?

Consider this code (type names genericised for the purposes of example): // Bound to ListBox.ItemsSource _items = new ObservableCollection<Item>(); // ...Items are added here ... // Specify custom IComparer for this collection view _itemsView = CollectionViewSource.GetDefaultView(_items) ((ListCollectionView)_itemsView).CustomSort = n...

Ranking newer items fairly?

Using StackOverflow itself as an example, if you had any such system where entries were voted and viewed in order of rank based on this, how do you compensate to sort newer entries fairly? That is, if ten bad answers are given and upvoted, how do you make sure people see the new entry that might be better, but hasn't had time to gather v...

How can I sort List<T> based on properties of T?

My Code looks like this : Collection<NameValueCollection> optionInfoCollection = .... List<NameValueCollection> optionInfoList = new List<NameValueCollection>(); optionInfoList = optionInfoCollection.ToList(); if(_isAlphabeticalSoting) Sort optionInfoList I tried optionInfoList.Sort() but it is not working. ...

Sort a single String in Java

Is there a native way to sort a String by its contents in java? E.g. String s = "edcba" -> "abcde" ...

How to sort NameValueCollection using a key in C#?

I've written following code and it works too - but I wanted to know whether their is better way than this : NameValueCollection optionInfoList = ..... ; if (aSorting) { optionInfoListSorted = new nameValueCollection(); String[] sortedKeys = optionInfoList.AllKeys; Ar...

Why is my simple comparator broken?

I have a class, which I have simplified to this: final class Thing { private final int value; public Thing(int value) { this.value = value; } public int getValue() { return value; } @Override public String toString() { return Integer.toString(value); } } I want to sort an array of th...

Is std::list<>::sort stable?

I couldn't find any definitive answer to this question. I suppose most implementation use merge sort that is stable but, is the stability a requirement or a side effect? ...

how to sort list of FileInfo in IronPython

Given a list of FileInfo objects, how do I sort them by date? Specifically I want to sort them by CreationTime in descending order. ...

Python: Sort a dictionary by value

I have a dictionary of values read from 2 fields in a database: a string field and a numeric field. The string field is unique so that is the key of the dictionary. I can sort on the keys, but how can I sort based on the values? Note: I have read this post 72899 and probably could change my code to have a list of dictionaries but since...