sorting

How to sort Core Data fetched properties

The Core Data Documentation states that: The fetch request associated with the [fetched] property can have a sort ordering, and thus the fetched property may be ordered. How do I specify the sort descriptors for the fetched property in Xcode's data model editor? I can't find a relevant field anywhere. I'm developing for the iPhon...

Customize the sorting in datagrid in flex

I have a column with 4 fields named : a> Main, b> Forward c> Back d> Link, if I use pre-defined sorting of datagrid with the column names which will be alphabetically, then the order is c>Back b>Forward d> Link a> Main. But, I do not want to sort based on the alphabets. I prefer to sort by names of the column fields. i.e. somehow give pr...

Why is F#'s Seq.sortBy much slower than LINQ's IEnumerable<T>.OrderBy extension method?

I've recently written a piece of code to read some data from a file, store it in a tuple and sort all the collected data by the first element of the tuple. After some tests I've noticed that using Seq.sortBy (and Array.sortBy) is extremely slower than using IEnumerable.OrderBy. Below are two snippets of code which should show the behavio...

Does DataView.ToTable() keep a descending sort order?

Hi everyone! I have a problem with sorting a DataTable. I'm using DataView.Sort and then DataView.ToTable() to get the sorted table. Then I go through the table row by row and create nodes in a TreeView which is shown in a desktop application. My problem is that I can sort the data in ascending order and it is shown in the TreeView in...

How do I sort a string array alphabetically by length?

By alphabetically by length I mean as follows: given: { "=", "==>>", "=>>", "=>", "!>" } I want to get out: !> = => =>> ==>> I'm currently just using OrderBy(x => x.Length).ToArray() anyone got a better lambda? EDIT: I'm going about this ALL wrong, please vote to close! ...

Sorting an List<> with my custom order which is stored in another List (C#)?

Hi there, Can anyone help.. I have a generic list like so IList<itemTp> itemTps; itemTp basically is a class (has a number of properties) and one property on this is "code" I need to be able to sort it an specific order which i have set in another List. This list is a simple list that lists the order (starting from first to las...

after using $files = new DirectoryIterator() in PHP, how do you sort the items?

We can get the files in a directory in PHP by $files = new DirectoryIterator() after that is there an easy way to sort the items in a particular order for displaying them? thanks. ...

Sorting certain values to the top

I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`, `name`, `country`) VALUES (1, 'Foo', 'us'), (2, 'Bar', 'jp'), (3, 'Baz', 'us'), (4, 'Foo2', 'se'), (5, 'Baz2', 'jp'), (6, 'Bar3', 'jp'); Now, I want to be able to get a paginated list of stores that begins with the customers country. For examp...

I have two unordered integer arrays, and i need to know how many integers these arrays have in common

I'm working in a LAMP environment, so PHP is the language; at least i can use python. As the title said i have two unordered integer arrays. $array_A = array(13, 4, 59, 38, 9, 69, 72, 93, 1, 3, 5) $array_B = array(29, 72, 21, 3, 6) I want to know how many integers these array have in common; in the example as you see the result is 2...

a sortable list/grid control in boa constructor

In my project there's a need for a multi-column list control. I wish the list could be automatically sorted upon clicking on the column header. Since i'm using Boa constructor, the solution should not be too obtrusive, i.e. compatible with Boa's ability to read and regenerate the code. So I thought, there can be either a built-in cont...

Sorting a List of LIst by the Value of the sublist

private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>(); ...populate.. records.add(subList); } For example, subList has three Strings - a, b, and c. I want to sort the records by the value of b in subList. records at 0 has a list of "...

NSSortDescriptor for comparing CLLocation objects in Cocoa/iPhone

I have an array of CLLocation objects and I'd like to be able to compare them to get distance from a starting CLLocation object. The math is straight forward but I'm curious if there is a convenience sort descriptor to go about doing this? Should I avoid NSSortDescriptor and write a custom compare method + bubble sort? I'm usually compar...

Can SQLite sort naturally?

Can SQLite sort naturally? For example, CREATE TABLE animals ( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL ); INSERT INTO animals (name) VALUES ('Monkey'); INSERT INTO animals (name) VALUES ('manatee'); SELECT name FROM animals ORDER BY name; name ---------- Monkey manatee I would prefer the results to be ...

Sort a list of strings based on regular expression match or something similar

I have a text file that looks a bit like: random text random text, can be anything blabla %A blabla random text random text, can be anything blabla %D blabla random text random text, can be anything blabla blabla %F random text random text, can be anything blabla blabla random text random text, %C can be anything blabla blabla When I ...

Problem with custom IComparer for List (sort) - c#

Hi, can anyone help, i have problem doing a sort, I thought i had it sorted but appears not to be working. I have a List which stores the following values 8,6,10,11,7 I also have another List (accessories in my class and it has a propert called accessoryId current the classes are in the order of id which is currenty 6,7,8,10,11) H...

Conditional sorting in MySQL?

I have "tasks" table with 3 fields: date priority (0,1,2) done (0,1) What I am trying to achieve is with the whole table sorted by done flag, tasks that are not done should be sorted by priority, while tasks that are done should be sorted by date: Select * from tasks order by done asc If done=0 additionally order by priority desc I...

Sorting a Python list by key... while checking for string OR float?

Ok, I've got a list like this (just a sample of data): data = {"NAME": "James", "RANK": "3.0", "NUM": "27.5" ... } Now, if I run something like this: sortby = "NAME" //this gets passed to the function, hence why I am using a variable sortby instead data.sort(key=itemgetter(sortby)) I get all the strings sorted properly - alphabetic...

Add new datagridRow, sort the datagrid and give serial numbers, in FLEX

Hi, I have a datagrid. I add a row to the datagrid using an ADD button. Once I add, I sort the datagrid based on a column. I also provide the serial numbers i.e. row numbers as first column to the datagrid. But, the serial number function does not apply after sorting. Hence, a new row added for e.g. row 5, based on sorting should be row...

plist or sqlite

I have to store a huge amount of data on IPhone then sort and search it as per requirement. Can anyone suggest to me which of SQLite or plist should I use? I was thinking of using SQLite. Which of plist and SQLite takes less processing time in searching and sorting? If some one has some reference guide then let me know. Regards ...

Is CollectionViewSource in WPF optimal?

Many WPF examples use CollectionViewSource as DataSource for DataBinding. It provides sorting and other useful functions. My question is, shouldn't this be done in Database? I mean in SQL? I bet it's 10times quicker. Isn't CollectionViewSource too slow? Thanks ...