我有一个混合数组,我需要按数字,字母,然后按数字排序 -
['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) 我最近改变了我的项目,包括一个更好的集成接口.我真的不知道如何从我的类继承我的接口的一个表单(用于更新表单控件)访问一个方法.下面是一些应该有助于清晰的代码片段.
//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)