<commit_before>/* @flow */

import React, { Component, PropTypes } from 'react';
import Connect from '../../../modules/store/Connect';
import PassUserProp from '../../../modules/store/PassUserProp';
import Rooms from '../views/Rooms';
import { ROLE_FOLLOWER } from '../../../lib/Constants';

const ITEM_LOADING = { type: 'loading' };

const filterInvalidRels = data => data.map(result => {
	if (!result.room || typeof result.room.type === 'string') {
		return ITEM_LOADING;
	}

	if (!result.roomrel || typeof result.roomrel.type === 'string') {
		return ITEM_LOADING;
	}

	return result;
});

const sortPlacesByTag = data => data.slice().sort((a, b) => {
	if (a.room && a.room.tags && b.room && b.room.tags) {
		const aTag = a.room.tags[0];
		const bTag = b.room.tags[0];

		if (aTag === bTag) {
			return 0;
		}

		if (aTag > bTag) {
			return 1;
		}

		if (aTag < bTag) {
			return -1;
		}
	}
<commit_msg>fix(ui): sort the places in apartment-first, city-last<commit_after>/* @flow */

import React, { Component, PropTypes } from 'react';
import Connect from '../../../modules/store/Connect';
import PassUserProp from '../../../modules/store/PassUserProp';
import Rooms from '../views/Rooms';
import { ROLE_FOLLOWER } from '../../../lib/Constants';

const ITEM_LOADING = { type: 'loading' };

const filterInvalidRels = data => data.map(result => {
	if (!result.room || typeof result.room.type === 'string') {
		return ITEM_LOADING;
	}

	if (!result.roomrel || typeof result.roomrel.type === 'string') {
		return ITEM_LOADING;
	}

	return result;
});

const sortPlacesByTag = data => data.slice().sort((a, b) => {
	if (a.room && a.room.tags && b.room && b.room.tags) {
		const aTag = a.room.tags[0];
		const bTag = b.room.tags[0];

		if (aTag === bTag) {
			return 0;
		}

		if (aTag > bTag) {
			return -1;
		}

		if (aTag < bTag) {
			return 1;
		}
	}

{'fraction_non_alphanumeric': 0.19622641509433963, 'fraction_numerical': 0.005390835579514825, 'mean_word_length': 3.0791208791208793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5099410', 'n_tokens_mistral': 717, 'n_tokens_neox': 670, 'n_words': 164}