Sort a list of object identifiers: Difference between revisions
Sort a list of object identifiers (view source)
Revision as of 14:19, 25 February 2017
, 7 years ago→{{header|Haskell}}
(→{{header|Haskell}}: Tidied the Data.Text.split variant) |
|||
Line 174:
import Data.List (sort, intercalate)
-- SORTING OBJECT IDENTIFIERS ------------------------------------------------
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 $
[ "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"
|