小编raj*_*dav的帖子

如何在javascript中对混合数字/字母数字数组进行排序

我有一个混合数组,我需要按数字,字母,然后按数字排序 -

['A1', 'A10', 'A11', 'A12', 'A3A', 'A3B', 'A3', 'A4', 'B10', 'B2', 'F1', '1', '2', 'F3']
Run Code Online (Sandbox Code Playgroud)

我如何将其排序为:

['1', '2', 'A1', 'A2', 'A3', 'A3A', 'A3B', 'A4', 'A10', 'A11', 'A12', 'B2', 'B10', 'F1', 'F3']
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的:

var reA = /[^a-zA-Z]/g;
var reN = /[^0-9]/g;
function sortAlphaNum(a, b) {
    var AInt = parseInt(a.Field, 10);
    var BInt = parseInt(b.Field, 10);

    if (isNaN(AInt) && isNaN(BInt)) {
        var aA = (a.Field).replace(reA, "");
        var bA = (b.Field).replace(reA, "");
        if (aA === bA) {
            var aN = parseInt((a.Field).replace(reN, ""), …
Run Code Online (Sandbox Code Playgroud)

javascript sorting jquery angularjs

8
推荐指数
1
解决办法
1284
查看次数

如何在其他类中使用非静态方法而不在C#中创建对象

我最近改变了我的项目,包括一个更好的集成接口.我真的不知道如何从我的类继承我的接口的一个表单(用于更新表单控件)访问一个方法.下面是一些应该有助于清晰的代码片段.

 //this is the double click event from where i have to call SelectDeal method

   private void TodayEventsGridView_DoubleClick(object sender, EventArgs e)

    {
        DealModule _dealModule = new DealModule();

        // i dont want to create an obect of class DealModule()
        try
        {
            this.Cursor = Cursors.WaitCursor;
            _dealModule.SelectDeal(DealKey);

        }
        catch (Exception ex)
        {
            MessageBox.Show("Warning: " + this.ToString() + " " + System.Reflection.MethodInfo.GetCurrentMethod().Name + "\n" + ex.Message, ex.GetType().ToString());
        }
        finally
        {
            this.Cursor = Cursors.Default;
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# methods class

0
推荐指数
1
解决办法
1241
查看次数

标签 统计

angularjs ×1

c# ×1

class ×1

javascript ×1

jquery ×1

methods ×1

sorting ×1