---
title: "List Operator"
description: "Filter, sort, and select elements from arrays"
icon: "filter"
---

The List Operator node processes arrays by filtering, sorting, and selecting specific elements. Use it when you need to work with mixed file uploads, large datasets, or any array data that requires separation or organization before downstream processing.

<Frame caption="List Operator node interface">
  <img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/522a0c932aab93d4f3970168412f759e.png" alt="List Operator interface" />
</Frame>

## The Array Processing Problem

Most workflow nodes expect single values, not arrays. When you have mixed content like `[image.png, document.pdf, audio.mp3]` in one variable, you need to separate this into focused streams that downstream nodes can process effectively.

The List Operator acts as an intelligent router, using filters to separate mixed arrays and prepare them for specialized processing.

<Frame caption="Array processing workflow example">
  <img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/812d1b2f167065e17df8392b2cb3cc8a.png" alt="Array processing example" />
</Frame>

## Supported Data Types

The node handles different array types with appropriate filtering options:

**Array[string]** - Text lists, categories, names, or any string collections

**Array[number]** - Numeric data, scores, measurements, or calculations  

**Array[file]** - Mixed file uploads with rich metadata filtering capabilities

## Operations

### Filtering

Extract specific items based on their attributes. For file arrays, filter by:

<Tabs>
  <Tab title="Content Properties">
    **Type** - Filter by content category: image, document, audio, video
    
    **MIME Type** - Precise content type identification (image/jpeg, application/pdf, etc.)
    
    **Extension** - File extensions (.pdf, .jpg, .mp3, .docx, etc.)
  </Tab>
  
  <Tab title="File Properties">
    **Size** - File size constraints for processing limits
    
    **Name** - Filename patterns or specific names
    
    **Transfer Method** - Distinguish between local uploads and URL-based files
  </Tab>
</Tabs>

### Sorting

Organize filtered results by any attribute:

**Ascending (ASC)** - Smallest to largest values, A-Z alphabetical order

**Descending (DESC)** - Largest to smallest values, Z-A reverse order

### Selection

Choose specific elements from the processed array:

**Take First N** - Select the first 1-20 items after filtering and sorting

**First Record** - Return only the first matching element as a single value

**Last Record** - Return only the last matching element as a single value

## Output Variables

**result** - Complete filtered and sorted array for bulk processing

**first_record** - Single element from the beginning, perfect for "primary" or "latest" item selection

**last_record** - Single element from the end, useful for "most recent" or "final" selection

## Mixed File Processing Example

Handle workflows where users upload both documents and images:

<Frame caption="Mixed file processing workflow">
  <img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/610358293217e54b55b7e1d4d16bf83c.png" alt="Mixed file processing example" />
</Frame>

**Implementation Steps:**

1. **Configure Mixed Uploads** - Enable file upload features to accept multiple file types
2. **Split by Type** - Use separate List Operator nodes with different filters:
   - Filter for `type = "image"` → route to LLM with vision capabilities
   - Filter for `type = "document"` → route to Document Extractor
3. **Process Appropriately** - Images get analyzed directly, documents get text extraction
4. **Combine Results** - Merge processed outputs into unified responses

This pattern automatically routes different file types to appropriate processors, creating seamless multi-modal user experiences.

## Common Use Cases

**File Type Routing** - Separate mixed uploads into specialized processing pipelines based on content type.

**Data Filtering** - Extract relevant subsets from large datasets based on specific criteria.

**Content Prioritization** - Sort and select the most important or recent items from collections.

**Quality Control** - Filter out invalid, oversized, or unsupported content before processing.

**Batch Preparation** - Organize data into manageable chunks for downstream iteration or parallel processing.

## Best Practices

**Plan Filter Criteria** - Define clear filtering rules based on your downstream processing requirements.

**Use Appropriate Output Types** - Choose between full arrays, first record, or last record based on how downstream nodes will use the data.

**Handle Empty Results** - Consider what happens when filters return no matches and plan appropriate fallback logic.

**Test with Real Data** - Verify filtering behavior with actual user uploads to ensure reliable operation in production.