Filter Array of Editor Elements

I am wanting to hide or show buttons and text depending on an input and would like to filter the buttons to hide them or show them. I am not sure if this is possible or I am making a simple error with the notation:

export function TitleClick ( title ) {
let button = “#” + title + “Ascend”

console . log ( button ) 

**let**  sortButtons  =  $w ( "#mTypeAscend, #mTypeDescend, #waiversDescend, #waiversAscend, #dateJoinedAscend, #dateJoinedDescend, #nameAscend, #nameDescend, #lastNameAscend, #lastNameDescend" ) 
    
**let**  hideButtons  =  sortButtons . filter ( item  =>  item  !=  '"$w(' + button + ')"' ); 
console . log ( hideButtons ) 
hideButtons . forEach ( element  => { 
    element . hide () 
}); 

$w ( “#” + title + “Ascend” ). show ()
}

I have attempted several different ways and the hideButtons array always includes the filtered item.

Thanks

Further to this - is it possible to filter an array of elements by which one is showing or hidden or collapsed etc?