sorting

Persist sorting from DataGrid to ItemsSource collection

隐身守侯 提交于 2020-01-06 03:25:26
问题 I have a DataGrid and I'm trying to do the Sort thing the most straightforward way: by clicking on the header of each column. This is working great on the View ( in the MVVM context ), but I want to sort the underlying ViewModel collection ( ObservableCollection ) too. Any suggestions on how to implement the source collection? 回答1: Bind the grid to a ListCollectionView , initialised with the ObservableCollection . The grid will use your pre-created ICollectionView instead of creating it's own

gridview only ASC is working on sorting

点点圈 提交于 2020-01-06 03:01:08
问题 So I have sorting working but it only runs Ascending. When I click it again just runs Ascending still. I debugged it and the sortDirection never changes. here is my sort code. I looked into using viewstate but couldn't find a clean way of using it for this situation. private string ConvertSortDirectionToSql(SortDirection sortDirection) { string newSortDirection = String.Empty; switch (sortDirection) { case SortDirection.Ascending: newSortDirection = "ASC"; break; case SortDirection.Descending

sort list of struct of different types in net 2.0

妖精的绣舞 提交于 2020-01-06 02:47:32
问题 Does anyone know how to sort a list of struct with different types (sample code below)? We are currently using Net 2.0, so we cannot use Linq. Thanks in advance! public struct dataKeys { private long key1; private long key2; private string key3; public long Key1; { get { return key1;} set { key1 = value; } } public long Key2; { get { return key2;} set { key2 = value; } } public string Key3; { get { return key3;} set { key3 = value; } } } . . . List<dataKeys> dataKeyList = new List<dataKeys>()

Sort sql result by occurence of a set of keywords

柔情痞子 提交于 2020-01-06 02:45:51
问题 I'm trying to do a little search engine for my website. First of all, user type in some keywords and go to result page that use this code : $result = array(); $keyword_tokens = explode(' ', $keywords); $keyword_tokens = array_map( function($keywords) { return mysql_real_escape_string(trim($keywords)); }, $keyword_tokens ); $sql = "SELECT * FROM search_table WHERE concat(title, description) LIKE '%"; $sql .= implode("%' OR concat(title, description) LIKE '%", $keyword_tokens) . "%' ORDER BY

Sorting FreqDist in NLTK with get vs get()

被刻印的时光 ゝ 提交于 2020-01-06 02:35:11
问题 I am playing around with NLTK and the module freqDist import nltk from nltk.corpus import gutenberg print(gutenberg.fileids()) from nltk import FreqDist fd = FreqDist() for word in gutenberg.words('austen-persuasion.txt'): fd[word] += 1 newfd = sorted(fd, key=fd.get, reverse=True)[:10] So I am playing around with NLTK and have a question regarding the sort portion. When I run the code like this it properly sorts the freqDist object. However when I run it with get() instead of get I encounter

iOS: Two Entities - Fetch, Merge, and Sort

会有一股神秘感。 提交于 2020-01-06 02:26:27
问题 I need to perform a fetch from two different entities, merge them, and then sort them based on a field that both entities have: 'lastModifiedDate'. lastModifiedDate is NSDate NSFetchRequest *fetchRequest1 = [[NSFetchRequest alloc] init]; NSFetchRequest *fetchRequest2 = [[NSFetchRequest alloc] init]; NSEntityDescription *entity1 = [NSEntityDescription entityForName:@"Entity1" inManagedObjectContext:self.managedObjectContext]; [fetchRequest1 setEntity:entity1]; NSEntityDescription *entity2 =

sorting integers in a arraylist of objects

蹲街弑〆低调 提交于 2020-01-06 02:25:08
问题 I'm starting with Java, and my problem is that I have an Arraylist of objects("Articulos", means Articles), and this object has properties (like name, price, etc...). I want to sort the Arraylist by the price of each object. Here's what I've tried. First, I fill the Arraylist manually: public static void Introducir_Articulo(){ Articulo a=new Articulo(); System.out.println("Codigo del articulo: "+(art.size()+1)); if(a.codArt==0){ a.codArt++; } else { a.codArt+=art.size(); } System.out.println(

efficient xslt conditional increment

夙愿已清 提交于 2020-01-06 02:16:07
问题 In this question i asked how to perform a conditional increment. The provided answer worked, but does not scale well on huge data-sets. The Input: <Users> <User> <id>1</id> <username>jack</username> </User> <User> <id>2</id> <username>bob</username> </User> <User> <id>3</id> <username>bob</username> </User> <User> <id>4</id> <username>jack</username> </User> </Users> The desired output (in optimal time-complexity): <Users> <User> <id>1</id> <username>jack01</username> </User> <User> <id>2</id

Forward Back Records in MySQL with the same DATA in the primary

…衆ロ難τιáo~ 提交于 2020-01-06 02:05:26
问题 I have a table that is is sorted 1st by Reminder Date then ID Table Looks like: ID | remind_date 1 2011-01-23 2 2010-02-21 4 2011-04-04 5 2011-04-04 6 2009-05-04 I am using a PHP front end to move forward and back thur the records. I want to have forward and back buttons but i am running into a problem with the 2 reminder dates that are the same. Just to note the ID's are NOT in order, they are here but in the actual database they are mixed up when sorting by reminder_date The select

Forward Back Records in MySQL with the same DATA in the primary

雨燕双飞 提交于 2020-01-06 02:05:08
问题 I have a table that is is sorted 1st by Reminder Date then ID Table Looks like: ID | remind_date 1 2011-01-23 2 2010-02-21 4 2011-04-04 5 2011-04-04 6 2009-05-04 I am using a PHP front end to move forward and back thur the records. I want to have forward and back buttons but i am running into a problem with the 2 reminder dates that are the same. Just to note the ID's are NOT in order, they are here but in the actual database they are mixed up when sorting by reminder_date The select