Skip to main content
sunilc0007
September 29, 2022
Solved

How to get second highest digit from array?

  • September 29, 2022
  • 11 replies
  • 0 views

Hello community,

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

Thanks in advance

    Best answer by harshitb6843

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

    11 replies

    Participating Frequently
    September 29, 2022

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

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

    sunilc0007
    September 29, 2022

    It shows error

    The function 'sortintegerarray' is unavailable.

    harshitb6843
    September 29, 2022

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

    harshitb6843
    September 29, 2022

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

    stefanhelzle0001
    Brainy
    October 1, 2022

    Very neat approach :-)

    amans0009
    September 29, 2022

    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
    )