---
title: "How to sort alphanumeric word in array in ios?"  
description: "How to sort alphanumeric word in array in ios?"  
author: "Anonymous User"  
published: 2014-11-11  
updated: 2014-11-12  
canonical: https://www.mindstick.com/forum/2557/how-to-sort-alphanumeric-word-in-array-in-ios  
category: "iphone"  
tags: ["ios", "objective c", "sorting"]  
reading_time: 1 minute  

---

# How to sort alphanumeric word in array in ios?

I have a [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) with 10 [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) called [products](https://www.mindstick.com/news/2358/apple-will-use-us-made-semiconductors-in-its-products-to-lessen-its-dependency-on-asia) which is sorted by [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources), this is the current [log](https://www.mindstick.com/articles/126269/the-main-uses-of-log-cabins) now.

for ([int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) i=0;i<products.count; i++)

{

NSLog(@"%@",products[i]);

}

The [Output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular):

Product1

Product10

Product2

Product3

Product4

Product5

Product6

Product7

Product8

Product9

I need to sort it in following [order](https://www.mindstick.com/articles/12276/how-timely-order-deliveries-can-improve-customer-experience):

Product1

Product2

Product3

Product4

Product5

Product6

Product7

Product8

Product9

Product10

## Replies

### Reply by Royce Roy

You can use this code to sort array. Use to search the numeric value in string.

```
NSArray * products = [[NSArray alloc] initWithObjects:@"Product1",@"Product10",@"Product2",@"Product3",@"Product4",@"Product5",@"Product6",@"Product7",@"Product8",@"Product9", nil];products = [products sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {        return [(NSString *)obj1 compare:(NSString *)obj2 options:NSNumericSearch];    }];NSLog(@"products : %@", products);And the log display :products : (    Product1,    Product2,    Product3,    Product4,    Product5,    Product6,    Product7,    Product8,    Product9,    Product10)
```


---

Original Source: https://www.mindstick.com/forum/2557/how-to-sort-alphanumeric-word-in-array-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
