Sort a list of object identifiers: Difference between revisions

m
(→‎{{header|Haskell}}: Tidied the Data.Text.split variant)
Line 174:
import Data.List (sort, intercalate)
 
-- SORTING OBJECT IDENTIFIERS ------------------------------------------------
idSortoidSort :: [String] -> [String]
idSort =
oidSort =
(intercalate "." <$>) .
((show <$>) <$>) . sort . ((readInt <$>) <$>) . (splitString '.' <$>)
 
-- GENERIC FUNCTIONS ---------------------------------------------------------
splitString :: Char -> String -> [String]
splitString c s = unpack <$> split (c ==) (pack s)
Line 185 ⟶ 187:
readInt xs = read xs :: Int
 
-- TEST ----------------------------------------------------------------------
main :: IO ()
main =
mapM_ putStrLn $
idSortoidSort
[ "1.3.6.1.4.1.11.2.17.19.3.4.0.10"
, "1.3.6.1.4.1.11.2.17.5.2.0.79"
9,655

edits