sorting - How can I sort my image sizes on both coordinates? -


i have list of string in form of xxx x numbers 4 digits long(they image sizes in (pixels)x(pixels)).

for example:

["192x192","64x84","96x96","64x64","292x192","32x32","64x12"] 

using function mysort insertion sort looks @ number x:

mysort []  = [] mysort [x] = [x] mysort (x:xs) = insert (mysort xs)     insert [] = [x]           insert (y:ys) | takeuntilx x <= takeuntilx y = x : y : ys                         | otherwise = y : insert ys 

i this:

["192x192","292x192","32x32","64x84","64x64","64x12","96x96"] 

which partly sorted, of sorted "64x**" remaing in original order want them sorted this:

["192x192","292x192","32x32","64x12","64x64","64x84","96x96"] 

what better solution - modifying function mysort or writing new function sorts partially sorted list? can give me the basic idea how either?

import data.list import data.list.split  res = map (intercalate "x") . sort . map (spliton "x") 

i'm using data.list.split http://hackage.haskell.org/package/split


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -