Sort a list of object identifiers: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: changed/added comments and whitespace, added whitespace to the ouput.)
Line 134: Line 134:
=={{header|Haskell}}==
=={{header|Haskell}}==
<lang Haskell>import Data.List ( sort , intercalate )
<lang Haskell>import Data.List ( sort , intercalate )

oid :: [String]
oid = ["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" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.4" ,
"1.3.6.1.4.1.11150.3.4.0.1" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.1" ,
"1.3.6.1.4.1.11150.3.4.0"]


splitString :: Eq a => (a) -> [a] -> [[a]]
splitString :: Eq a => (a) -> [a] -> [[a]]
Line 152: Line 144:
convertIntListToString = intercalate "." . map show
convertIntListToString = intercalate "." . map show


orderOID :: [String]
orderOID :: [String] -> [String]
orderOID = map convertIntListToString . sort .
orderOID = map convertIntListToString . sort . map ( map read . splitString '.' )

map ( map read . splitString '.' ) $ oid
oid :: [String]
oid = ["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" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.4" ,
"1.3.6.1.4.1.11150.3.4.0.1" ,
"1.3.6.1.4.1.11.2.17.19.3.4.0.1" ,
"1.3.6.1.4.1.11150.3.4.0"]


main :: IO ( )
main :: IO ( )
main = do
main = do
mapM_ putStrLn orderOID</lang>
mapM_ putStrLn $ orderOID oid</lang>


{{out}}
{{out}}