I'm a bit of a NSSortDescriptor n00b. I think, though, it is the right tool for what I need to do:
I have an NSArray consisting of objects with keys, say, "name" and "time". Instead of verbalizing it, here's an example:
input:
name: time
B: 4
C: 8
B: 5
C: 4
A: 3
C: 2
A: 1
A: 7
B: 6
desired output:
name: time
A: 1 <---
A: 3
A: 7
C: ...
I have an array with a list of objects sorted alphabetically ignoring the letters case (used a lowerCaseString method) and I need to sort it into an array of arrays one for each letter +1 for non alpha characters.
A simple way of doing it would be to loop through the source array with a giant 27 stack deep if else if else if else.... Ne...
I have a MySQL table with many rows. The table has a popularity column. If I sort by popularity, I can get the rank of each item. Is it possible to retrieve the rank of a particular item without sorting the entire table? I don't think so. Is that correct?
An alternative would be to create a new column for storing rank, sort the entire t...
How do you implement a preserve sort in a Qt QTreeWidget? I.e. I would like the previous order of the tree preserved as much as possible. This allows the user to do something like click the "Name" column header and then the "Date" column header, and the resulting tree shows the items in the QTreeWidget by Date and then by Name.
...
What is the easiest way to insert a new object into an array of objects at the index position 0? No jQuery; MooTools okay; no unshift() because it's undefined in IE according to w3schools.
...
I have some data which i output in a for-each loop in xslt. I have paging working on the list, but not the sort selector.
The user should be able to sort on 2 values (created data, and a number field on each item). The default sort method is the create date, but when the user clicks "Sort by number" the list should instead order by a nu...
I'm having a issue sorting an arraylist of custom objects by a string field.
This is the code I'm trying to do:
arrRegion.Sort(delegate(Portal.Entidad.Region x, Portal.Entidad.Region y)
{
return x.RegNombre.CompareTo(y.RegNombre);
});
But I'm getting ...
I wonder if there is support in STL for this:
Say I have an class like this :
class Person
{
public:
int getAge() const;
double getIncome() const;
..
..
};
and a vector:
vector<Person*> people;
I would like to sort the vector of people by their age:
I know I can do it the following way:
class AgeCmp
{
public:
bool oper...
Hello,
I am creating to pg_dumps, DUMP1 and DUMP2.
DUMP1 and DUMP2 are exactly the same, except DUMP2 was dumped in REVERSE order of DUMP1.
Is there anyway that I can sort the two DUMPS so that the two DUMP files are exactly the same (when using a diff)?
I am using PHP and linux. I tried using "sort" in linux, but that does not work....
Let's say, I have an instance of IQueryable. How can I found out by which parameters it was ordered?
Here is how OrderBy() method looks like (as a reference):
public static IOrderedQueryable<T> OrderBy<T, TKey>(
this IQueryable<T> source, Expression<Func<T, TKey>> keySelector)
{
return (IOrderedQueryable<T>)source.Provider.Crea...
This is confusing to me. I have a function that does this:
void ListAllStoredLocations(NSString *SearchTerm){
NSMutableDictionary *item;
NSString* filePath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/Preferences/yourprogram.plist"];
item = [[[NSMutab...
Hi,
I'm trying to implement QuickSort algorithm program in Java, but I'm getting incorrect answer.
public class QuickSort{
public static void main(String[] args){
int arr[]={12,34,22,64,34,33,23,64,33};
int i=0;
int j=arr.length;
while(i<j){
i=quickSort(arr,i,i+1,j-1);
}
...
(Using the latest MVC 2 RC 2) I'm trying to sort some XML in LINQ (C#) by an element's attribute's value...
var sites = from s in xDoc.Element("sites").Elements("site")
orderby s.Attribute("name")
select s;
But when I pass this to my View I get the exception:
Exception Details: System.ArgumentException: At least one object must imple...
So, I'm looking for the most efficient way to sort a bunch of pairs<string, float> by value, because I need to get the 3 highest entries of a high number of pairs.
My natural reaction was to use a sortedList, but apparently it only sorts by key, and I cant use the reversed list solution because I know for a fact that the strings are uni...
I have listView in my (C#) program. I change some items background and foreground colors after I have added items to listview. All items are OK and Colors too.
If I use sorting with listView, then all first 6 items colors have been disappeared. And some colors of rest items are in disorder.
This effect happens with default sorting and my...
Do you know of any library that would provide a well-tested concurrent quicksort or mergesort algorithm for Java?
We've had issues on a 16-(virtual)-cores Mac where only one core (!) was working using the default Java sorting algo and it was, well, not good to see that very fine machine be completely underused. So we wrote our own (I w...
I'm trying to create a nested comment system using PHP and MySQL. But I'm stuck
My Database structure is id, body, time, reply and depth.
A regular comment's reply field will be '0'. If it's replying to another it will correspond to the id of the comment it's replying to.
depth means how deep it is from the highest parent
So if this...
I have a list of string, which is most likely, but not guaranteed to contain a list of numerics, i.e.,
{"1", "6", "2", "21", "89"}
What is the way to sort the string list so that it will always appear in ascending order?
I can't parse the string to numeric first before doing the sorting simply because the string can contain non nume...
I have csv file with 14 columns and I want to sort it in ruby by 6th column then by 2nd and then by 11th column.
There is nice method .sort_by but it works only for two columns, doesn't it. And array_of_arrays.sort_by {|e| [e[2], e[0],e[1]],} doesn't work.
so let's say in the sample below I want it to be sorted by 3rd,1st,2nd columns
...
Hi
Basically I have defined a Tree data type which is defined as follows:
data Tree a = Empty
| Leaf a
| Node (Tree a) a (Tree a)
deriving (Eq, Ord, Show)
Now I have to create a function to insert a value into an ordered tree (it doesn't have to sort the tree, just add the value). This is what I've come up with so far:
insert :: a -...