Skip to main content
sunilc0007
Known Participant
Sep 29, 2022 12:31 PM UTC
Solved

How to get second highest digit from array?

Hello community,

can anyone suggest me how to get second highest number from an array.

Thanks in advance

    harshitb6843
    Brainy
    Sep 29, 2022 12:36 PM UTC

    a!localVariables(
      local!array: {1,2,3,4,5,6},
      max(difference(todecimal(local!array),max(local!array)))
    )

    11 replies

    Participating Frequently
    Sep 29, 2022 12:36 PM UTC

    Check this plugin https://community.appian.com/b/appmarket/posts/sort-utilities

    index(
      sortintegerarray(
        {1,20,8,9,2},
        true()
      ),
      2,
      {}
    )

    sunilc0007
    Known Participant
    Sep 29, 2022 12:42 PM UTC

    It shows error

    The function 'sortintegerarray' is unavailable.

    harshitb6843
    Brainy
    Sep 29, 2022 12:42 PM UTC

    That is a plugin. Do not use plugin for this simple usecase. 

    harshitb6843
    Brainy
    Sep 29, 2022 12:36 PM UTC

    a!localVariables(
      local!array: {1,2,3,4,5,6},
      max(difference(todecimal(local!array),max(local!array)))
    )

    stefanhelzle0001
    Brainy
    Oct 1, 2022 2:52 PM UTC

    Very neat approach :-)

    amans0009
    Participating Frequently
    Sep 29, 2022 12:37 PM UTC

    a!localVariables(
      local!val:{1,2,3,4,0},
      local!max1: max(local!val),
      local!ans: a!forEach(
        items: local!val,
        expression: if(fv!item=local!max1,{},fv!item)
      ),
      local!max2:max(local!ans),
      local!max2
    )