mercredi 22 février 2017

How to sort of string array in ruby on rails

I am working on ruby on rails and i am new here as well ruby on rails. I am working on one project and find some issue of sorting an array of string which contains images name. I have tried many algorithm which i know doesn't help me. When i call service for image extraction it gives me like this array.

Example:

["page-1_1.png", "page-1_10.png", "page-1_11.png", "page-1_2.png", "page-1_3.png", "page-1_4.png", "page-1_5.png", "page-1_6.png", "page-1_7.png", "page-1_8.png", "page-1_9.png"]

I want to sort this array like this:

["page-1_1.png", "page-1_2.png", "page-1_3.png", "page-1_4.png", "page-1_5.png", "page-1_6.png", "page-1_7.png", "page-1_8.png", "page-1_9.png", "page-1_10.png", "page-1_11.png"]

I had tried many things to sort but can't get any solutions. please help me. Sorry for silly question

Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire