# Compare

A plugin can export the function Compare to override the default file panel sorting algorithm.

    int WINAPI Compare(
      HANDLE hPlugin,
      const struct PluginPanelItem *Item1,
      const struct PluginPanelItem *Item2,
      unsigned int Mode
    );

### Parameters

hPlugin
Plugin handle, returned by OpenPlugin or OpenFilePlugin.
Item1, Item2
Pointers to PluginPanelItem structures to compare.
Mode
See Sort modes

### Return value

This function returns an int value that is:

`-1` if Item1 `<` Item2
`0` if Item1 `==` Item2
`1` if Item1`>` Item2
`-2` if the default FAR compare function should be used for this sort mode.

### Remarks

The standard RTL qsort function that implements and unstable sorting algorithm is used by FAR for sorting needs. In other words if array elements are equal to the compare function then on the panels they will be shown in random order, that changes upon each redrawing of the panel.