public function render() {

		$type = $this->getEntityType();
		$options = $this->getOptions();

		$options['base_url'] = $this->getBaseURL();
		$options['list_id'] = $this->getId();

		$list = elgg_list_entities($options, $this->getter);
		$list = elgg_format_element('div', [
			'class' => 'elgg-sortable-list-view',
		], $list);
		
		if (empty($this->search_query) && empty($this->filters) && !preg_match_all("/<ul.*>.*<\/ul>/s", $list)) {
			// List is empty
			return $list;
		}

		$sort_options = (array) elgg_extract('sort_options', $options, $this->getSortOptions());
		$filter_options = (array) elgg_extract('filter_options', $options, $this->getFilterOptions());
		$subtype_options = (array) elgg_extract('subtype_options', $options, $this->getSubtypeOptions());

		$show_subtype = elgg_extract('show_subtype', $options, false) && !empty($subtype_options);
		$show_sort = elgg_extract('show_sort', $options, false) && !empty($sort_options);
		$show_search = elgg_extract('show_search', $options, false);
		if (isset($options['show_rel'])) {
			// BC
			$show_filter = $options['show_rel'] && !empty($filter_options);
		} else {
			$show_filter = elgg_extract('show_filter', $options, false) && !empty($filter_options);
		}

		$form = '';
		if ($show_sort || $show_search || $show_filter || $show_subtype) {

			$form_vars = [
				'entity_type' => $this->getEntityType(),
				'show_sort' => $show_sort,
				'show_search' => $show_search,
				'show_filter' => $show_filter,
				'show_subtype' => $show_subtype,
				'filter' => array_map(function($e) {
					return $e['filter'];
				}, $this->filters),
				'query' => $this->search_query,
				'sort' => array_map(function($e) {
					return strtolower("{$e['field']}::{$e['direction']}");
				}, $this->sorts),
				'sort_options' => $sort_options,
				'filter_options' => $filter_options,
				'subtype_options' => $subtype_options,
				'expand_form' => elgg_extract('expand_form', $options),
			];

			$form = elgg_view_form('lists/sort', array(
				'action' => $this->getBaseURL(),
				'method' => 'GET',
				'disable_security' => true,
				'class' => 'elgg-form-sortable-list',
			), $form_vars);
		}

		echo elgg_format_element('div', [
			'id' => "$type-sort-{$this->getId()}",
			'class' => "elgg-sortable-list $type-sort-list",
		], $form . $list);
	}