Sort Array Using Custom Selector With Two Arguments

I'm trying to sort an array of NSStrings but i'm unsure how to actually pass parameters into the @selector method. Here is why I'm trying to do

//After the optional: id like to pass a UITextField.text but not sure how. NSArray *sortedSection = [wordSection sortedArrayUsingSelector:@selector(sortValue:optional:)];

Here is the method I'm attempting to use.

- (NSComparisonResult) sortValue:(NSString *)otherString optional:(NSString *)otherLetters;

Any help is greatly appreciated.

-------------Problems Reply------------

would this help?

NSArray *tm;
NSSortDescriptor *name = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
NSSortDescriptor *age = [NSSortDescriptor sortDescriptorWithKey:@"age" ascending:YES];
[tm sortedArrayUsingDescriptors:[NSArray arrayWithObjects:name, age, nil]];

didn't really understand what is in wordSection, what you like to sort and what will be in the UITextField.text

Category:objective c Views:0 Time:2010-12-19

Related post

  • Is it possible to Sort Arrays with custom objects containing String elements localized AND with correct Numbers in Cocoa Touch? 2009-11-18

    Assumed having the class Account with Name and accountNo both as NSStrings. I want to sort an Array of Accounts either by name or by accountNo. The sort should be done localized. If I use NSSortDescriptors as described in the Guides I have the option

  • Sorting array of custom objects using the value of an internal object's instance variable 2012-01-30

    (sorry about the long title) I have a custom object Person, which in turn has an NSSet which has several custom objects called Appointment. A Person therefore can have several appointments. Appointment has the values startTime and endTime. These are

  • Sorting Array of Custom Class Objects 2011-06-30

    I am facing problem that is of sorting. The scenario is explained as: i have a class (Suppose of person) and it has suppose 4 attributes (firstName, lastName, Address, salary) i am creating its object and making a collection of all attributes and put

  • How to sort array by custom column name 2012-04-21

    I am working on a wordpress site and i need to sort the array of some users by a custom column name 'IDlisting' How can i sort this array by 'IDlisting'? Array ( [0] => stdClass Object ( [ID] => 6 [user_login] => adri [user_url] => [user_

  • Sort array with custom objects 2012-03-24

    I'm trying to sort an array, filled with objects from a class i wrote. The class i wrote contains an NSString itself, as the "name". So what i wanna do, is to sort the array, based on the name property the objects contain. I tried the simple: [anArra

  • Sorting an Array of custom objects by a dictionary included in the custom object: How? 2009-12-05

    I have an array of custom objects. The objects includes a dictionary. Something like this: CustomDataModel *dataModel; dataModel.NSString dataModel.NSDictionary dataModel.image I'd like to sort by one of the objects in the dictionary: dataModel.NSDic

  • Sort Array of NSString By Custom Method 2010-11-15

    How would I go about sorting an array of NSString Objects by a custom method. For example I have a method -(int)calculateValue:(NSString *)aString I would like to sort an array by descending order based on the returned value from this method. So for

  • Objective-C: Sort array using arguments 2011-03-29

    I'm trying to sort an array passing an argument to the selector. For instance, I have an array of locations and I want to sort this array based on the distance they have from a certain point (for instance, my current location). This is my selector, h

  • How can I sort arrays in php by a custom alphabet? 2011-06-14

    I want to sort arrays by key in php. but the alphabet I'm using is not the normal English alphabet, but a self created alphabet. Is this possible? My alphabet is $alphabet = "AjawbpfmnrhHxXsSqkgtTdD ="; The array is like this: Array ( [=k_0] => Ar

  • Custom sort array in PHP 2011-08-17

    Possible Duplicate: How can I sort arrays in php by a custom alphabet? For example, i have six words: banana, apple, love, zasca, japanese, car Is there a way to sort in alphabetic order, using this custom order: "j, c, z, l, a"? --------------Soluti

  • Sorting an array using custom logic 2012-04-22

    I have an array which I want to sort using some custom logic. new string[] {"bRad", "Charles", "sam", "lukE", "vIctor"} Now I want to sort this according to positional occurrence of capital letters in a string. If the first letter is capital then ign

  • PHP sort an array by custom value 2011-05-06

    The array below should be sorted by the first number of cat_url_title. Array ( [0] => Array ( [cat_id] => 14 [parent_id] => 2 [cat_url_title] => 20-a-43m ) [1] => Array ( [cat_id] => 13 [parent_id] => 2 [cat_url_title] => 16-a

  • Javascript sort custom comparator function - sorting a sorted array 2011-08-23

    I have an array of objects of the following form: arr[0] = { 'item1' : 1234, 'item2' : 'a string' }; I sort it first by 'item1' which is straightforward. Now i want to sort arr (which is sorted by 'item1') again but this time by 'item2' but only for

  • Sort arrays of primitive types in descending order 2008-10-18

    I've got a large array of primitive types (double). How do I sort the elements in descending order? Unfortunately the Java API doesn't support sorting of primitive types with a Comparator. One workaround would be to sort and then reverse: double[] ar

  • javascript sorting array of mixed strings and null values 2010-02-24

    When soritng an array made of a mix of strings, null values and zeros, i get the result not properly as exptected, null values seem to get sorted as if they were 'null' strings. I did this (tested on FireFox): var arr1 = arr2 = [null, "b", "c", "d",

  • sort array according to date 2010-11-30

    Sort array according to date, problem is date saved in string format can this is possible to sort array without change date in NSDate object.(Core Data). string format is mm/dd/yyyy --------------Solutions------------- You can create the sort with so

  • Custom selector for visual closeness of elements in a specific direction with jQuery based on rendered location and size 2011-07-10

    I need selectors which are able to retrieve correct results for visual closeness queries like the following: $("h2:closestTo('div#example')"); $("input:below('label:contains(\"Username\")')"); Closeness and distances should be dependent of the visual

  • How do I sort arrays using vbscript? 2008-11-06

    The question says it all really, but... I'm scanning through a file looking for lines that match a certain regex pattern, and then I want to print out the lines that match but in alphabetical order. I'm sure this is trivial but vbscript isn't my back

  • Parsing multiple XML feeds with PHP into one sorted array 2009-04-09

    I want to create a sortable list that looks something like $VAR1[0], $VAR2[0]... $VAR1[1], $VAR2[1]... The data comes from multiple same structured xml files: $xmlfile=" <Level1> <Level2> <Level2Item VAR1="1" VAR2="2" ... /> <Lev

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.174 (s). 11 q(s)