Timeline for Find second largest value in array
Current License: CC BY-SA 4.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 25, 2019 at 1:22 | vote | accept | CommunityBot | ||
| Jan 23, 2019 at 20:37 | history | edited | jesse_b | CC BY-SA 4.0 |
added 263 characters in body
|
| Jan 23, 2019 at 14:03 | comment | added | steeldriver |
You could save one pipe if you reverse sort, so that the answer is always in second place e.g. printf '%s\n' "${array[@]}" | sort -rn | awk NR==2 (likely head + tail is more efficient though) or (at least with GNU Coreutils, which support the null delimiters) printf '%s\0' "${array[@]}" | sort -rzn | cut -d '' -f2
|
|
| Jan 23, 2019 at 13:16 | history | answered | jesse_b | CC BY-SA 4.0 |