Handling Sorting by Matching Rules142 Netscape Directory Server Plug-In Programmer’s Guide • August 20022. Find the corresponding attribute in the attributes passed into the function.Make sure to check for subtypes of an attribute (for example, “cn;lang-ja”) inthe filter and in the attributes specified by attrs.You can call the slapi_attr_type_cmp() function to compare the attribute inthe filter against the attributes passed in as arguments.3. Using the query operator to determine how the values should be compared,compare the values from the filter against the values from the values in theattribute.4. Return one of the following values:m 0 if the values of the attribute match the value specified in the filter.m -1 if the values don’t match.m An LDAP error code (a positive number) if an error occurred.Handling Sorting by Matching RulesIf you have set up indexing by a matching rule, you can also sort search results bythat matching rule. The server can use the keys in the index to sort the searchresults.When processing a request to sort by a matching rule, the server does thefollowing:1. In a new Slapi_PBlock parameter block, the server sets the followingparameters:m Sets the OID in the SLAPI_PLUGIN_MR_OID parameter.m Sets the attribute type (of the value being added, modified, or removed) inthe SLAPI_PLUGIN_MR_TYPE parameter.m Sets the SLAPI_PLUGIN_MR_USAGE parameter toSLAPI_PLUGIN_MR_USAGE_SORT. (This indicates that the created indexerobject will be used for sorting, not indexing.)2. Next, the server calls the indexer factory function (specified in theSLAPI_PLUGIN_MR_INDEXER_CREATE_FN parameter) for the plug-in.3. The server generates the index keys for the values to be sorted:m The server sets the SLAPI_PLUGIN_MR_VALUES parameter to the array ofberval structures containing the values to be sorted.