{# {% set result = [] %} #}
{# {% set isTopProfilesExist = top_profile is defined and null != top_profile and null != profiles %}
{{dump( top_profile in profiles.array|keys )}}
{% if isTopProfilesExist and top_profile in profiles.array|keys %}
{% set result = [] %}
{% for key, profile in profiles.array %}
{% if profile != top_profile %}
{% set result = result|merge([profile])%}
{% endif %}
{% endfor %}
{% set result = [top_profile]|merge(result) %}
{% endif %}
{{dump( result )}} #}
{% set profiles_array = [] %}
{% if profiles != null %}
{% if profiles.array is defined %}
{# Legacy listing provider #}
{% set profiles_array = profiles.array %}
{% if top_profile is defined and null != top_profile %}
{% set profiles_array = [top_profile]|merge(profiles_array) %}
{% endif %}
{% else %}
{# New listing microservice. Profiles array already contains top placement #}
{% set profiles_array = profiles %}
{% endif %}
{% endif %}
{% set hidePreferredButton = hidePreferredButton is defined ? hidePreferredButton : false %}
{% set likeButton = likeButton is defined ? likeButton : false %}
{%- for profile in profiles_array -%}
{%- set lazyLoad = loop.index == 1 -%}
{% include 'ProfileList/profile.html.twig' with {profile: profile, lazyLoad: lazyLoad} %}
{%- endfor -%}