通过desc,asc排序功能

时间:2017-08-16 12:16:59

标签: javascript reactjs ecmascript-6 material-ui

我的Table组件包含columns数组和数据数组。我需要排序列和更新表的状态。我的方法从列接收两个参数 key (列键)和可排序(真或假列可排序或不可归类),我搞乱了什么?排序表列的最佳解决方案是什么?如何使其简单,并按数字和字符串排序

const columns = [
    {
        key: 'deviceType',
        label:'Device Type',
        numeric: false,
    }, {
        key: 'deviceID',
        label:'Device ID',
        sortable: true,
        numeric: true,
        // cellRenderer: ({item, key}) =>
        //          <Button >Default</Button>,
    }, {
        key: 'name',
        label: 'Name',
        sortable: false,
        numeric: false,

    },{
        key: 'currentVersion',
        label: 'Current Version',
        sortable: false,
        numeric: false,
    },{
        key: 'location',
        label: 'Location',
        sortable: false,
        numeric: false,
    },{
        key: 'status',
        label: 'Status',
        sortable: false,
        numeric: false,
    },{
        key: 'lastAliveMessage',
        label: 'Last alive message',
        sortable: false,
        numeric: false,
    }, {
        key: 'action',
        label: 'Actions',
        cellRenderer: () => <SimpleMenu />,
    }]

const data = [
    { key: 1, deviceType: 'Tag', deviceID: 1, name:'Tag For sending an ', location: 'Room_104', status: 'assigned'},
    { key: 2, deviceType: 'Tag', deviceID: 2, name:'Tag For sending an ', location: 'Room_104', status: 'assigned'},
    { key: 3, deviceType: 'Tag', deviceID: 3, name:'Tag For sending an ', location: 'Room_104', status: 'assigned'},
    { key: 4, deviceType: 'Tag', deviceID: 4, name:'Tag For sending an ', location: 'Room_104', status: 'assigned'},
    { key: 5, deviceType: 'Tag', deviceID: 5, name:'Tag For sending an ', location: 'Room_104', status: 'assigned'},
]

class EnhancedTable extends Component {
    state = {
        selected: [],
        data,
        order: 'asc',
        search: '',
    }

    handleRequestSort = (key, sortable) => {
        let order = 'desc'

        // if (this.state.order.by === key && this.state.order.direction === 'desc') {
        //     order = 'asc'
        // }
        if (sortable && this.state.order.direction === 'desc') {
            order = 'asc'
        }
        const data = this.state.data.sort(
            (a, b) => {
                order === 'desc' ? b[key] > a[key] : a[key] > b[key]},
        )

        this.setState({ data, order })
    }

1 个答案:

答案 0 :(得分:3)

if self.alpha < 0.0: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() The above exception was the direct cause of the following exception: TransportableException Traceback (most recent call last) C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in retrieve(self) 681 if 'timeout' in getfullargspec(job.get).args: --> 682 self._output.extend(job.get(timeout=self.timeout)) 683 else: C:\Anaconda3\lib\multiprocessing\pool.py in get(self, timeout) 643 else: --> 644 raise self._value 645 TransportableException: TransportableException ___________________________________________________________________________ ValueError Wed Aug 16 19:23:55 2017 PID: 18804 Python 3.6.2: C:\Anaconda3\python.exe ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>) 126 def __init__(self, iterator_slice): 127 self.items = list(iterator_slice) 128 self._size = len(self.items) 129 130 def __call__(self): --> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items] self.items = [(<function _fit_and_score>, (MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], 0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, <function _passthrough_scorer>, memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), 10, {'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True})] 132 133 def __len__(self): 134 return self._size 135 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in <listcomp>(.0=<list_iterator object>) 126 def __init__(self, iterator_slice): 127 self.items = list(iterator_slice) 128 self._size = len(self.items) 129 130 def __call__(self): --> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items] func = <function _fit_and_score> args = (MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], 0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, <function _passthrough_scorer>, memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), 10, {'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}) kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True} 132 133 def __len__(self): 134 return self._size 135 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py in _fit_and_score(estimator=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], y=0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, scorer=<function _passthrough_scorer>, train=memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), test=memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), verbose=10, parameters={'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}, fit_params={}, return_train_score=True, return_parameters=True, return_n_test_samples=True, return_times=True, error_score='raise') 233 234 try: 235 if y_train is None: 236 estimator.fit(X_train, **fit_params) 237 else: --> 238 estimator.fit(X_train, y_train, **fit_params) estimator.fit = <bound method BaseMultilayerPerceptron.fit of ML...n_fraction=0.1, verbose=False, warm_start=False)> X_train = user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns] y_train = 1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64 fit_params = {} 239 240 except Exception as e: 241 # Note fit time as time until error 242 fit_time = time.time() - start_time ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in fit(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns], y=1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64) 613 614 Returns 615 ------- 616 self : returns a trained MLP model. 617 """ --> 618 return self._fit(X, y, incremental=False) self._fit = <bound method BaseMultilayerPerceptron._fit of M...n_fraction=0.1, verbose=False, warm_start=False)> X = user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns] y = 1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64 619 620 @property 621 def partial_fit(self): 622 """Fit the model to data matrix X and target y. ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in _fit(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns], y=1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64, incremental=False) 320 if not hasattr(hidden_layer_sizes, "__iter__"): 321 hidden_layer_sizes = [hidden_layer_sizes] 322 hidden_layer_sizes = list(hidden_layer_sizes) 323 324 # Validate input parameters. --> 325 self._validate_hyperparameters() self._validate_hyperparameters = <bound method BaseMultilayerPerceptron._validate...n_fraction=0.1, verbose=False, warm_start=False)> 326 if np.any(np.array(hidden_layer_sizes) <= 0): 327 raise ValueError("hidden_layer_sizes must be > 0, got %s." % 328 hidden_layer_sizes) 329 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in _validate_hyperparameters(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False)) 386 if not isinstance(self.shuffle, bool): 387 raise ValueError("shuffle must be either True or False, got %s." % 388 self.shuffle) 389 if self.max_iter <= 0: 390 raise ValueError("max_iter must be > 0, got %s." % self.max_iter) --> 391 if self.alpha < 0.0: self.alpha = array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]) 392 raise ValueError("alpha must be >= 0, got %s." % self.alpha) 393 if (self.learning_rate in ["constant", "invscaling", "adaptive"] and 394 self.learning_rate_init <= 0.0): 395 raise ValueError("learning_rate_init must be > 0, got %s." % ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ___________________________________________________________________________ During handling of the above exception, another exception occurred: JoblibValueError Traceback (most recent call last) <ipython-input-20-7c1268d1d451> in <module>() 9 orders_prior1 = orders_prior.groupby('product_id').filter(lambda x: len(x) >= 3).fillna(0) 10 # up = orders_prior['product_id'].unique() ---> 11 clf.fit(orders_prior1 [['user_id','order_number','order_dow','order_hour_of_day','days_since_prior_order']] ,orders_prior1['product_id'], orders_prior1['user_order']) 12 13 # ord_pred.partial_fit(orders_prior.fillna(0).iloc[0:894]\ C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in fit(self, X, y, groups) 943 train/test set. 944 """ --> 945 return self._fit(X, y, groups, ParameterGrid(self.param_grid)) 946 947 C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in _fit(self, X, y, groups, parameter_iterable) 562 return_times=True, return_parameters=True, 563 error_score=self.error_score) --> 564 for parameters in parameter_iterable 565 for train, test in cv_iter) 566 C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in __call__(self, iterable) 766 # consumption. 767 self._iterating = False --> 768 self.retrieve() 769 # Make sure that we get a last message telling us we are done 770 elapsed_time = time.time() - self._start_time C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in retrieve(self) 717 ensure_ready = self._managed_backend 718 backend.abort_everything(ensure_ready=ensure_ready) --> 719 raise exception 720 721 def __call__(self, iterable): JoblibValueError: JoblibValueError ___________________________________________________________________________ Multiprocessing exception: ........................................................................... C:\Anaconda3\lib\runpy.py in _run_module_as_main(mod_name='ipykernel_launcher', alter_argv=1) 188 sys.exit(msg) 189 main_globals = sys.modules["__main__"].__dict__ 190 if alter_argv: 191 sys.argv[0] = mod_spec.origin 192 return _run_code(code, main_globals, None, --> 193 "__main__", mod_spec) mod_spec = ModuleSpec(name='ipykernel_launcher', loader=<_f...nda3\\lib\\site-packages\\ipykernel_launcher.py') 194 195 def run_module(mod_name, init_globals=None, 196 run_name=None, alter_sys=False): 197 """Execute a module's code without importing it F:\thecads_vm-master\eds\Final Project\Instacart\<ipython-input-20-7c1268d1d451> in <module>() 6 } 7 ord_pred = MLPClassifier(hidden_layer_sizes = (100,1)) 8 clf = GridSearchCV(estimator=ord_pred,param_grid=parameters,n_jobs=-1,verbose = 10) 9 orders_prior1 = orders_prior.groupby('product_id').filter(lambda x: len(x) >= 3).fillna(0) 10 # up = orders_prior['product_id'].unique() ---> 11 clf.fit(orders_prior1 [['user_id','order_number','order_dow','order_hour_of_day','days_since_prior_order']] ,orders_prior1['product_id'], orders_prior1['user_order']) 12 13 # ord_pred.partial_fit(orders_prior.fillna(0).iloc[0:894]\ 14 # [['user_id','order_number','order_dow','order_hour_of_day','days_since_prior_order']]\ 15 # ,orders_prior.iloc[0:894]['product_id'], up) ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in fit(self=GridSearchCV(cv=None, error_score='raise', ...rain_score=True, scoring=None, verbose=10), X= user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], y=0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, groups=0 11 1 11 2 ...Name: user_order, Length: 32433710, dtype: object) 940 941 groups : array-like, with shape (n_samples,), optional 942 Group labels for the samples used while splitting the dataset into 943 train/test set. 944 """ --> 945 return self._fit(X, y, groups, ParameterGrid(self.param_grid)) self._fit = <bound method BaseSearchCV._fit of GridSearchCV(...ain_score=True, scoring=None, verbose=10)> X = user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns] y = 0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64 groups = 0 11 1 11 2 ...Name: user_order, Length: 32433710, dtype: object self.param_grid = {'activation': ['logistic', 'relu', 'Tanh'], 'alpha': [array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06])], 'hidden_layer_sizes': [(10, 10, 10), (10, 10, 20), (10, 10, 30), (10, 10, 40), (10, 10, 50), (10, 10, 100), (10, 20, 10), (10, 20, 20), (10, 20, 30), (10, 20, 40), (10, 20, 50), (10, 20, 100), (10, 30, 10), (10, 30, 20), (10, 30, 30), (10, 30, 40), (10, 30, 50), (10, 30, 100), (10, 40, 10), (10, 40, 20), ...], 'learning_rate': ['constant', 'invscaling', 'adaptive']} 946 947 948 class RandomizedSearchCV(BaseSearchCV): 949 """Randomized search on hyper parameters. ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in _fit(self=GridSearchCV(cv=None, error_score='raise', ...rain_score=True, scoring=None, verbose=10), X= user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], y=0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, groups=0 11 1 11 2 ...Name: user_order, Length: 32433710, dtype: object, parameter_iterable=<sklearn.model_selection._search.ParameterGrid object>) 559 fit_params=self.fit_params, 560 return_train_score=self.return_train_score, 561 return_n_test_samples=True, 562 return_times=True, return_parameters=True, 563 error_score=self.error_score) --> 564 for parameters in parameter_iterable parameters = undefined parameter_iterable = <sklearn.model_selection._search.ParameterGrid object> 565 for train, test in cv_iter) 566 567 # if one choose to see train score, "out" will contain train score info 568 if self.return_train_score: ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object BaseSearchCV._fit.<locals>.<genexpr>>) 763 if pre_dispatch == "all" or n_jobs == 1: 764 # The iterable was consumed all at once by the above for loop. 765 # No need to wait for async callbacks to trigger to 766 # consumption. 767 self._iterating = False --> 768 self.retrieve() self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)> 769 # Make sure that we get a last message telling us we are done 770 elapsed_time = time.time() - self._start_time 771 self._print('Done %3i out of %3i | elapsed: %s finished', 772 (len(self._output), len(self._output), --------------------------------------------------------------------------- Sub-process traceback: --------------------------------------------------------------------------- ValueError Wed Aug 16 19:23:55 2017 PID: 18804 Python 3.6.2: C:\Anaconda3\python.exe ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in __call__(self=<sklearn.externals.joblib.parallel.BatchedCalls object>) 126 def __init__(self, iterator_slice): 127 self.items = list(iterator_slice) 128 self._size = len(self.items) 129 130 def __call__(self): --> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items] self.items = [(<function _fit_and_score>, (MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], 0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, <function _passthrough_scorer>, memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), 10, {'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}), {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True})] 132 133 def __len__(self): 134 return self._size 135 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in <listcomp>(.0=<list_iterator object>) 126 def __init__(self, iterator_slice): 127 self.items = list(iterator_slice) 128 self._size = len(self.items) 129 130 def __call__(self): --> 131 return [func(*args, **kwargs) for func, args, kwargs in self.items] func = <function _fit_and_score> args = (MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], 0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, <function _passthrough_scorer>, memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), 10, {'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}) kwargs = {'error_score': 'raise', 'fit_params': {}, 'return_n_test_samples': True, 'return_parameters': True, 'return_times': True, 'return_train_score': True} 132 133 def __len__(self): 134 return self._size 135 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py in _fit_and_score(estimator=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [32433710 rows x 5 columns], y=0 196 1 14084 2 ... Name: product_id, Length: 32433710, dtype: int64, scorer=<function _passthrough_scorer>, train=memmap([ 1606, 1610, 1618, ..., 32433707, 32433708, 32433709]), test=memmap([ 0, 1, 2, ..., 32190332, 32190334, 32190356]), verbose=10, parameters={'activation': 'logistic', 'alpha': array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]), 'hidden_layer_sizes': (10, 10, 10), 'learning_rate': 'constant'}, fit_params={}, return_train_score=True, return_parameters=True, return_n_test_samples=True, return_times=True, error_score='raise') 233 234 try: 235 if y_train is None: 236 estimator.fit(X_train, **fit_params) 237 else: --> 238 estimator.fit(X_train, y_train, **fit_params) estimator.fit = <bound method BaseMultilayerPerceptron.fit of ML...n_fraction=0.1, verbose=False, warm_start=False)> X_train = user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns] y_train = 1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64 fit_params = {} 239 240 except Exception as e: 241 # Note fit time as time until error 242 fit_time = time.time() - start_time ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in fit(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns], y=1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64) 613 614 Returns 615 ------- 616 self : returns a trained MLP model. 617 """ --> 618 return self._fit(X, y, incremental=False) self._fit = <bound method BaseMultilayerPerceptron._fit of M...n_fraction=0.1, verbose=False, warm_start=False)> X = user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns] y = 1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64 619 620 @property 621 def partial_fit(self): 622 """Fit the model to data matrix X and target y. ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in _fit(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False), X= user_id order_number order_dow orde... 7.0 [21606079 rows x 5 columns], y=1606 17762 1610 17762 1618 ... Name: product_id, Length: 21606079, dtype: int64, incremental=False) 320 if not hasattr(hidden_layer_sizes, "__iter__"): 321 hidden_layer_sizes = [hidden_layer_sizes] 322 hidden_layer_sizes = list(hidden_layer_sizes) 323 324 # Validate input parameters. --> 325 self._validate_hyperparameters() self._validate_hyperparameters = <bound method BaseMultilayerPerceptron._validate...n_fraction=0.1, verbose=False, warm_start=False)> 326 if np.any(np.array(hidden_layer_sizes) <= 0): 327 raise ValueError("hidden_layer_sizes must be > 0, got %s." % 328 hidden_layer_sizes) 329 ........................................................................... C:\Anaconda3\lib\site-packages\sklearn\neural_network\multilayer_perceptron.py in _validate_hyperparameters(self=MLPClassifier(activation='logistic', alph...on_fraction=0.1, verbose=False, warm_start=False)) 386 if not isinstance(self.shuffle, bool): 387 raise ValueError("shuffle must be either True or False, got %s." % 388 self.shuffle) 389 if self.max_iter <= 0: 390 raise ValueError("max_iter must be > 0, got %s." % self.max_iter) --> 391 if self.alpha < 0.0: self.alpha = array([ 1.00000000e-01, 1.00000000e-02, 1.0...0000000e-04, 1.00000000e-05, 1.00000000e-06]) 392 raise ValueError("alpha must be >= 0, got %s." % self.alpha) 393 if (self.learning_rate in ["constant", "invscaling", "adaptive"] and 394 self.learning_rate_init <= 0.0): 395 raise ValueError("learning_rate_init must be > 0, got %s." % ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() 进行了内部数组修改。而你忘了回来。

sort

或删除const data = this.state.data.slice() data.sort( (a, b) => { return order === 'desc' ? b[key] > a[key] : a[key] > b[key] }, )

{}