Sort a list of object identifiers: Difference between revisions
Sort a list of object identifiers (view source)
Revision as of 14:05, 25 February 2017
, 7 years ago→{{header|Haskell}}: Tidied the Data.Text.split variant
(→{{header|Haskell}}: Added a variant using split :: (Char -> Bool) -> Text -> [Text]) |
(→{{header|Haskell}}: Tidied the Data.Text.split variant) |
||
Line 174:
import Data.List (sort, intercalate)
[ "1.3.6.1.4.1.11.2.17.19.3.4.0.10"▼
((show <$>) <$>) . sort . ((readInt <$>) <$>) . (splitString '.' <$>)
, "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 c s = unpack <$> split (c ==) (pack s)
▲ ((intercalate "." <$>) . ((show <$>) <$>)) <$> sort $
readInt :: String -> Int
readInt xs = read xs :: Int
main :: IO ()
main =
idSort
▲ [ "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"
]</lang>
{{Out}}
<pre>1.3.6.1.4.1.11.2.17.5.2.0.79
|