Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an objective-c approach. Unfortunately, you will not have the fun of writing the AI portion, the sorting is built into the libraries already.</p> <pre><code>int north = 1, south = 3, east = 2, west =4; NSDictionary * nDict = [NSDictionary dictionaryWithObjectsAndKeys:@"north", @"name", [NSNumber numberWithInt:north], @"value", nil]; NSDictionary * sDict = [NSDictionary dictionaryWithObjectsAndKeys:@"south", @"name", [NSNumber numberWithInt:south], @"value", nil]; NSDictionary * eDict = [NSDictionary dictionaryWithObjectsAndKeys:@"east", @"name", [NSNumber numberWithInt:east], @"value", nil]; NSDictionary * wDict = [NSDictionary dictionaryWithObjectsAndKeys:@"west", @"name", [NSNumber numberWithInt:west], @"value", nil]; NSArray * toBeSorted = [NSArray arrayWithObjects:nDict,sDict,eDict,wDict,nil]; NSArray * sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"value" ascending:NO]]; NSArray * sorted = [toBeSorted sortedArrayUsingDescriptors:sortDescriptors]; NSLog(@"sorted %@", sorted); </code></pre> <p>Output</p> <pre><code>2012-01-23 19:50:21.079 TestEnvironment[19792:207] sorted ( { name = west; value = 4; }, { name = south; value = 3; }, { name = east; value = 2; }, { name = north; value = 1; } ) </code></pre> <p>Now you can check the highest priority by </p> <pre><code>NSString * highestPriority = [[sorted objectAtIndex:0] objectForKey:@"name"]; </code></pre> <p>Now you have some classes you can look up (<code>NSArray, NSDictionary, NSSortDescriptor, NSNumber</code>)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload