import { TREND_TAGS_SUCCESS,
  TREND_TAGS_HISTORY_SUCCESS,
  TOGGLE_TREND_TAGS
} from '../actions/trend_tags';
import Immutable from 'immutable';

const initialState = Immutable.Map({
  tags: Immutable.Map({
    updated_at: '',
    score: Immutable.Map(),
  }),
  history: Immutable.List(),
  visible: true,
});

export default function trend_tags(state = initialState, action) {
  switch(action.type) {
  case TREND_TAGS_SUCCESS:
    return state.set('tags', Immutable.fromJS(action.tags));
  case TREND_TAGS_HISTORY_SUCCESS:
    return state.set('history', Immutable.fromJS(action.tags));
  case TOGGLE_TREND_TAGS:
    return state.set('visible', !state.get('visible'));
  default:
    return state;
  }
}

@@ -432,61 +432,157 @@
     
-return state.set('tags', Immutable.fromJS(action.tags
+const tmp = Immutable.fromJS(action.tags);%0A    return state.set('tags', tmp.set('score', tmp.get('score').sort((a, b) =%3E %7B%0A      return b - a;%0A    %7D)
 ));%0A

Revert "cancel sorting trend tags in the UI side"