Last active
January 2, 2016 03:19
-
-
Save johnwalker/8243534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns nested-vector-ops) | |
(def nested-vector [[:salt 0 5 :deviation 5 10] | |
[:milk 5 4 :deviation 1 2] | |
[:cream 0 0 :deviation 0 0]]) | |
(->> | |
nested-vector | |
(remove (fn [[_ _ _ _ a]] (= "N/A" a))) | |
(sort-by (fn [[_ _ _ _ a]] a)) | |
(reverse)) |
Oh. Well, just change zero? to a predicate that tests for N/A, e.g. (= "N/A", and then move the argument in the sort-by function to the fifth position.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi...I get my nested vector from a database, then map a function that formats it and computes the deviation, actual data looks like below......so I don't have any keys within the the vector, ......would like to sort by index 5 in in each vector descending and if index 5 is N/A (not e.g a percentage)remove it from the list
[["151819" "ANTI HUMAN GLOBULIN SERUM 5ML " "6.0" 0 0 "N/A" "N/A"] ["151090" "ANTI SERUM A 10ML " "6.0" 0 0 "N/A" "N/A"] ["151094" "ANTI SERUM AB 10ML " "6.0" 0 0 "N/A" "N/A"] ["151092" "ANTI SERUM B 10ML " "6.0" 0 0 "N/A" "N/A"] ["151095" "ANTI SERUM D 10ML " "6.0" 0 0 "N/A" "N/A"] ["151825" "BLOOD GLUCOSE GLUCOMETER-CONTOUR " 0 0 0 "N/A" "N/A"] ["151829" "BLOOD GLUCOSE STRIPS(50 STRIPS)-CONTOUR " "12.0" 360.0 0 "3000.00 %" "N/A"] ["151828" "BLOOD GLUCOSE STRIPS(50 STRIPS)-SURESTEP" 0 360.0 0 "N/A" "N/A"]]
Thanks again