- for( i_position = 0; i_position < i_items -1 ; i_position ++ )
- {
- i_small = i_position;
- for( i = i_position + 1 ; i< i_items ; i++)
- {
- int i_test = 0;
-
- if( i_mode == SORT_TITLE )
- {
- i_test = strcasecmp( pp_items[i]->input.psz_name,
- pp_items[i_small]->input.psz_name );
- }
- else if( i_mode == SORT_TITLE_NUMERIC )
- {
- i_test = atoi( pp_items[i]->input.psz_name ) -
- atoi( pp_items[i_small]->input.psz_name );
- }
- else if( i_mode == SORT_DURATION )
- {
- i_test = pp_items[i]->input.i_duration -
- pp_items[i_small]->input.i_duration;
- }
- else if( i_mode == SORT_AUTHOR )
- {
- char *psz_a = vlc_input_item_GetInfo(
- &pp_items[i]->input,
- _( "Meta-information"), _("Artist") );
- char *psz_b = vlc_input_item_GetInfo(
- &pp_items[i_small]->input,
- _( "Meta-information"), _("Artist") );
- if( pp_items[i]->i_children == -1 &&
- pp_items[i_small]->i_children >= 0 )
- {
- i_test = 1;
- }
- else if( pp_items[i]->i_children >= 0 &&
- pp_items[i_small]->i_children == -1 )
- {
- i_test = -1;
- }
- // both are nodes
- else if( pp_items[i]->i_children >= 0 &&
- pp_items[i_small]->i_children >= 0 )
- {
- i_test = strcasecmp( pp_items[i]->input.psz_name,
- pp_items[i_small]->input.psz_name );
- }
- else if( psz_a == NULL && psz_b != NULL )
- {
- i_test = 1;
- }
- else if( psz_a != NULL && psz_b == NULL )
- {
- i_test = -1;
- }
- else if( psz_a == NULL && psz_b == NULL )
- {
- i_test = strcasecmp( pp_items[i]->input.psz_name,
- pp_items[i_small]->input.psz_name );
- }
- else
- {
- i_test = strcmp( psz_b, psz_a );
- }
- }
- else if( i_mode == SORT_TITLE_NODES_FIRST )
- {
- /* Alphabetic sort, all nodes first */
-
- if( pp_items[i]->i_children == -1 &&
- pp_items[i_small]->i_children >= 0 )
- {
- i_test = 1;
- }
- else if( pp_items[i]->i_children >= 0 &&
- pp_items[i_small]->i_children == -1 )
- {
- i_test = -1;
- }
- else
- {
- i_test = strcasecmp( pp_items[i]->input.psz_name,
- pp_items[i_small]->input.psz_name );
- }
- }
-
- if( ( i_type == ORDER_NORMAL && i_test < 0 ) ||
- ( i_type == ORDER_REVERSE && i_test > 0 ) )
- {
- i_small = i;
- }
- }
- p_temp = pp_items[i_position];
- pp_items[i_position] = pp_items[i_small];
- pp_items[i_small] = p_temp;
- }
- return VLC_SUCCESS;